diff --git a/.release-please-manifest.json b/.release-please-manifest.json index dbc9e2fa5a3..9e618998a6c 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,4 +1,5 @@ { + "handwritten/nodejs-datastore": "10.0.1", "packages/gapic-node-processing": "0.1.6", "packages/google-ads-admanager": "0.5.0", "packages/google-ads-datamanager": "0.1.0", @@ -23,6 +24,7 @@ "packages/google-cloud-apigeeconnect": "4.2.1", "packages/google-cloud-apigeeregistry": "2.2.1", "packages/google-cloud-apihub": "0.5.1", + "packages/google-cloud-apiregistry": "0.1.0", "packages/google-cloud-apphub": "0.6.1", "packages/google-cloud-asset": "6.3.1", "packages/google-cloud-assuredworkloads": "5.1.1", @@ -92,6 +94,7 @@ "packages/google-cloud-gkeconnect-gateway": "5.2.1", "packages/google-cloud-gkehub": "6.3.1", "packages/google-cloud-gkemulticloud": "2.3.0", + "packages/google-cloud-gkerecommender": "0.1.0", "packages/google-cloud-gsuiteaddons": "2.2.1", "packages/google-cloud-hypercomputecluster": "0.1.0", "packages/google-cloud-iap": "4.3.1", @@ -145,11 +148,11 @@ "packages/google-cloud-saasplatform-saasservicemgmt": "0.1.1", "packages/google-cloud-scheduler": "5.3.1", "packages/google-cloud-secretmanager": "6.1.1", + "packages/google-cloud-securesourcemanager": "0.8.1", "packages/google-cloud-security-privateca": "7.0.1", "packages/google-cloud-security-publicca": "2.2.1", "packages/google-cloud-securitycenter": "9.2.1", "packages/google-cloud-securitycentermanagement": "0.7.1", - "packages/google-cloud-securesourcemanager": "0.8.1", "packages/google-cloud-servicedirectory": "6.1.1", "packages/google-cloud-servicehealth": "0.7.1", "packages/google-cloud-shell": "4.1.1", @@ -216,7 +219,5 @@ "packages/google-storagetransfer": "4.2.1", "packages/google-streetview-publish": "0.4.1", "packages/grafeas": "6.1.1", - "packages/typeless-sample-bot": "3.1.1", - "packages/google-cloud-apiregistry": "0.1.0", - "packages/google-cloud-gkerecommender": "0.1.0" -} \ No newline at end of file + "packages/typeless-sample-bot": "3.1.1" +} diff --git a/handwritten/nodejs-datastore/.OwlBot.yaml b/handwritten/nodejs-datastore/.OwlBot.yaml new file mode 100644 index 00000000000..56f8c18e7f9 --- /dev/null +++ b/handwritten/nodejs-datastore/.OwlBot.yaml @@ -0,0 +1,26 @@ +# 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. + + +deep-remove-regex: + - /owl-bot-staging + +deep-copy-regex: + - source: /google/datastore/(v.*)/.*-nodejs + dest: /owl-bot-staging/nodejs-datastore/$1 + - source: /google/datastore/(admin/v.*)/.*-nodejs + dest: /owl-bot-staging/nodejs-datastore/$1 + +begin-after-commit-hash: fb91803ccef5d7c695139b22788b309e2197856b + diff --git a/handwritten/nodejs-datastore/.eslintignore b/handwritten/nodejs-datastore/.eslintignore new file mode 100644 index 00000000000..c4a0963e9bd --- /dev/null +++ b/handwritten/nodejs-datastore/.eslintignore @@ -0,0 +1,8 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ +samples/generated/ +system-test/**/fixtures diff --git a/handwritten/nodejs-datastore/.eslintrc.json b/handwritten/nodejs-datastore/.eslintrc.json new file mode 100644 index 00000000000..78215349546 --- /dev/null +++ b/handwritten/nodejs-datastore/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "./node_modules/gts" +} diff --git a/handwritten/nodejs-datastore/.gitattributes b/handwritten/nodejs-datastore/.gitattributes new file mode 100644 index 00000000000..33739cb74e4 --- /dev/null +++ b/handwritten/nodejs-datastore/.gitattributes @@ -0,0 +1,4 @@ +*.ts text eol=lf +*.js text eol=lf +protos/* linguist-generated +**/api-extractor.json linguist-language=JSON-with-Comments diff --git a/handwritten/nodejs-datastore/.gitignore b/handwritten/nodejs-datastore/.gitignore new file mode 100644 index 00000000000..d4f03a0df2e --- /dev/null +++ b/handwritten/nodejs-datastore/.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/handwritten/nodejs-datastore/.jsdoc.js b/handwritten/nodejs-datastore/.jsdoc.js new file mode 100644 index 00000000000..4e00e5b8f28 --- /dev/null +++ b/handwritten/nodejs-datastore/.jsdoc.js @@ -0,0 +1,55 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file 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 2025 Google LLC', + includeDate: false, + sourceFiles: false, + systemName: '@google-cloud/datastore', + theme: 'lumen', + default: { + outputSourceFiles: false + } + }, + markdown: { + idInHeadings: true + } +}; diff --git a/handwritten/nodejs-datastore/.mocharc.js b/handwritten/nodejs-datastore/.mocharc.js new file mode 100644 index 00000000000..0b600509bed --- /dev/null +++ b/handwritten/nodejs-datastore/.mocharc.js @@ -0,0 +1,29 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. +const config = { + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000, + "recursive": true +} +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/handwritten/nodejs-datastore/.nycrc b/handwritten/nodejs-datastore/.nycrc new file mode 100644 index 00000000000..b18d5472b62 --- /dev/null +++ b/handwritten/nodejs-datastore/.nycrc @@ -0,0 +1,24 @@ +{ + "report-dir": "./.coverage", + "reporter": ["text", "lcov"], + "exclude": [ + "**/*-test", + "**/.coverage", + "**/apis", + "**/benchmark", + "**/conformance", + "**/docs", + "**/samples", + "**/scripts", + "**/protos", + "**/test", + "**/*.d.ts", + ".jsdoc.js", + "**/.jsdoc.js", + "karma.conf.js", + "webpack-tests.config.js", + "webpack.config.js" + ], + "exclude-after-remap": false, + "all": true +} diff --git a/handwritten/nodejs-datastore/.prettierignore b/handwritten/nodejs-datastore/.prettierignore new file mode 100644 index 00000000000..9340ad9b86d --- /dev/null +++ b/handwritten/nodejs-datastore/.prettierignore @@ -0,0 +1,6 @@ +**/node_modules +**/coverage +test/fixtures +build/ +docs/ +protos/ diff --git a/handwritten/nodejs-datastore/.prettierrc.js b/handwritten/nodejs-datastore/.prettierrc.js new file mode 100644 index 00000000000..d1b95106f4c --- /dev/null +++ b/handwritten/nodejs-datastore/.prettierrc.js @@ -0,0 +1,17 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +module.exports = { + ...require('gts/.prettierrc.json') +} diff --git a/handwritten/nodejs-datastore/.readme-partials.yml b/handwritten/nodejs-datastore/.readme-partials.yml new file mode 100644 index 00000000000..95804f1480e --- /dev/null +++ b/handwritten/nodejs-datastore/.readme-partials.yml @@ -0,0 +1,8 @@ +body: |- + ### Troubleshooting + #### Emulator returning `DEADLINE_EXCEEDED`, `java.lang.OutOfMemoryError` + *Reference Issue: [#95](https://github.com/googleapis/nodejs-datastore/issues/95)* + + When using the emulator, you may experience errors such as "DEADLINE_EXCEEDED" within your application, corresponding to an error in the emulator: "java.lang.OutOfMemoryError". These errors are unique to the emulator environment and will not persist in production. + + A workaround is available, provided by [@ohmpatel1997](https://github.com/ohmpatel1997) [here](https://github.com/googleapis/nodejs-datastore/issues/95#issuecomment-554387312). diff --git a/handwritten/nodejs-datastore/.repo-metadata.json b/handwritten/nodejs-datastore/.repo-metadata.json new file mode 100644 index 00000000000..553e9a71187 --- /dev/null +++ b/handwritten/nodejs-datastore/.repo-metadata.json @@ -0,0 +1,15 @@ +{ + "name": "datastore", + "name_pretty": "Google Cloud Datastore", + "product_documentation": "https://cloud.google.com/datastore/docs", + "client_documentation": "https://cloud.google.com/nodejs/docs/reference/datastore/latest", + "issue_tracker": "https://issuetracker.google.com/savedsearches/559768", + "release_level": "stable", + "language": "nodejs", + "repo": "googleapis/google-cloud-node", + "distribution_name": "@google-cloud/datastore", + "api_id": "datastore.googleapis.com", + "codeowner_team": "@googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk", + "api_shortname": "datastore", + "library_type": "GAPIC_COMBO" +} diff --git a/handwritten/nodejs-datastore/CHANGELOG.md b/handwritten/nodejs-datastore/CHANGELOG.md new file mode 100644 index 00000000000..39d47243685 --- /dev/null +++ b/handwritten/nodejs-datastore/CHANGELOG.md @@ -0,0 +1,942 @@ +# Changelog + +[npm history][1] + +[1]: https://www.npmjs.com/package/@google-cloud/datastore?activeTab=versions + +## [10.0.1](https://github.com/googleapis/nodejs-datastore/compare/v10.0.0...v10.0.1) (2025-05-08) + + +### Bug Fixes + +* Fix the compiler error blocking the release ([#1391](https://github.com/googleapis/nodejs-datastore/issues/1391)) ([ec91e14](https://github.com/googleapis/nodejs-datastore/commit/ec91e143254dbd8edaa262a5537199ecae4fd1f2)) + +## [10.0.0](https://github.com/googleapis/nodejs-datastore/compare/v9.2.1...v10.0.0) (2025-05-02) + + +### ⚠ BREAKING CHANGES + +* migrate to Node 18 ([#1384](https://github.com/googleapis/nodejs-datastore/issues/1384)) + +### Bug Fixes + +* **doc:** Fix param descriptions for filters ([#1346](https://github.com/googleapis/nodejs-datastore/issues/1346)) ([a18c169](https://github.com/googleapis/nodejs-datastore/commit/a18c169e3b67e4e46f8b6bb9eb7cb250a88e40b7)) +* More error visibility in nodejs-datastore ([#1389](https://github.com/googleapis/nodejs-datastore/issues/1389)) ([55934da](https://github.com/googleapis/nodejs-datastore/commit/55934da4c3b9436e8ccf6a0935d416f00a8e1e17)) +* Not check sub-property existence for `null` values ([#1330](https://github.com/googleapis/nodejs-datastore/issues/1330)) ([5c0ddbc](https://github.com/googleapis/nodejs-datastore/commit/5c0ddbca91c41e056443eb0b60449f3cdddd6e69)) + + +### Miscellaneous Chores + +* Migrate to Node 18 ([#1384](https://github.com/googleapis/nodejs-datastore/issues/1384)) ([43c3472](https://github.com/googleapis/nodejs-datastore/commit/43c34720095bf03c13394bab7cd3facdb2ffc985)) + +## [9.2.1](https://github.com/googleapis/nodejs-datastore/compare/v9.2.0...v9.2.1) (2024-11-06) + + +### Bug Fixes + +* Address edge cases for excluding large properties when using save ([#1356](https://github.com/googleapis/nodejs-datastore/issues/1356)) ([ceaff7e](https://github.com/googleapis/nodejs-datastore/commit/ceaff7ef468413ff10e03e0b3ed923b4b5a37a08)) +* Create a release ([#1353](https://github.com/googleapis/nodejs-datastore/issues/1353)) ([536873e](https://github.com/googleapis/nodejs-datastore/commit/536873e24bacc9477f1a9c4c5403ed08d5c8cc93)) + +## [9.2.0](https://github.com/googleapis/nodejs-datastore/compare/v9.1.0...v9.2.0) (2024-10-30) + + +### Features + +* Add FindNearest API to the stable branch ([#1333](https://github.com/googleapis/nodejs-datastore/issues/1333)) ([1d56433](https://github.com/googleapis/nodejs-datastore/commit/1d5643369226c5fc220779f4c90fa804d8f876af)) +* Update Go Datastore import path ([#1261](https://github.com/googleapis/nodejs-datastore/issues/1261)) ([bf3dafd](https://github.com/googleapis/nodejs-datastore/commit/bf3dafd8267c447a52f7764505042a60b1a9fd28)) + + +### Bug Fixes + +* Add excludeFromIndexes in the proper places for large properties of nested fields ([#1266](https://github.com/googleapis/nodejs-datastore/issues/1266)) ([9c7730a](https://github.com/googleapis/nodejs-datastore/commit/9c7730a35699be049beeac0c4bb469239971d471)) +* Query object description ([#1340](https://github.com/googleapis/nodejs-datastore/issues/1340)) ([ad2c6c0](https://github.com/googleapis/nodejs-datastore/commit/ad2c6c01b83f0ae42a3dc4268feb5f4b45890f7c)) + +## [9.1.0](https://github.com/googleapis/nodejs-datastore/compare/v9.0.0...v9.1.0) (2024-06-24) + + +### Features + +* New transaction feature ([#1239](https://github.com/googleapis/nodejs-datastore/issues/1239)) ([cdd2ee9](https://github.com/googleapis/nodejs-datastore/commit/cdd2ee98c50b48b9a2a8cfb2f66b84a5937b3783)) + + +### Bug Fixes + +* **deps:** Update dependency sinon to v18 ([#1250](https://github.com/googleapis/nodejs-datastore/issues/1250)) ([b7ff5c8](https://github.com/googleapis/nodejs-datastore/commit/b7ff5c86306f80d93f678a0638892c58a3b2088c)) + +## [9.0.0](https://github.com/googleapis/nodejs-datastore/compare/v8.7.0...v9.0.0) (2024-05-09) + + +### ⚠ BREAKING CHANGES + +* An existing method `UpdateVehicleLocation` is removed from service `VehicleService` ([#1248](https://github.com/googleapis/nodejs-datastore/issues/1248)) + +### Features + +* Query profiling feature ([#1221](https://github.com/googleapis/nodejs-datastore/issues/1221)) ([414dec4](https://github.com/googleapis/nodejs-datastore/commit/414dec4e1548f551be06df914d6b56362bdc1790)) + + +### Bug Fixes + +* An existing method `UpdateVehicleLocation` is removed from service `VehicleService` ([#1248](https://github.com/googleapis/nodejs-datastore/issues/1248)) ([ba79118](https://github.com/googleapis/nodejs-datastore/commit/ba79118ac00ccc3bb0380ee5693c3b687a7ae9c7)) +* Read time should be used for transaction reads ([#1171](https://github.com/googleapis/nodejs-datastore/issues/1171)) ([73a0a39](https://github.com/googleapis/nodejs-datastore/commit/73a0a39b4c0423a5b4802076cdce80fce7c9adda)) + +## [8.7.0](https://github.com/googleapis/nodejs-datastore/compare/v8.6.0...v8.7.0) (2024-04-02) + + +### Features + +* Add several fields to manage state of database encryption update ([#1243](https://github.com/googleapis/nodejs-datastore/issues/1243)) ([5d28cda](https://github.com/googleapis/nodejs-datastore/commit/5d28cda744c3bb11da5e72ea8a0f7d8d8e85c4b0)) + +## [8.6.0](https://github.com/googleapis/nodejs-datastore/compare/v8.5.0...v8.6.0) (2024-03-25) + + +### Features + +* Add new types ExplainOptions, ExplainMetrics, PlanSummary, ExecutionStats ([#1241](https://github.com/googleapis/nodejs-datastore/issues/1241)) ([6c409d5](https://github.com/googleapis/nodejs-datastore/commit/6c409d5c922288bd8286917b266cdb553cfd43cf)) +* Nodejs transaction redesign feature branch ([#1235](https://github.com/googleapis/nodejs-datastore/issues/1235)) ([1585d4a](https://github.com/googleapis/nodejs-datastore/commit/1585d4a4e1b4b16d198307a3e97ffcf156d000b1)) + + +### Bug Fixes + +* **deps:** Update dependency async-mutex to ^0.5.0 ([#1240](https://github.com/googleapis/nodejs-datastore/issues/1240)) ([0ba1281](https://github.com/googleapis/nodejs-datastore/commit/0ba1281efe16ef0b725937627445c32c36b9f705)) + +## [8.5.0](https://github.com/googleapis/nodejs-datastore/compare/v8.4.0...v8.5.0) (2024-02-06) + + +### Features + +* Trusted Private Cloud support, use the universeDomain parameter ([#1227](https://github.com/googleapis/nodejs-datastore/issues/1227)) ([10480ed](https://github.com/googleapis/nodejs-datastore/commit/10480edfdda99cde5fef470fbf163861528398a0)) + +## [8.4.0](https://github.com/googleapis/nodejs-datastore/compare/v8.3.0...v8.4.0) (2024-01-09) + + +### Features + +* Add new types QueryMode, QueryPlan, ResultSetStats ([#1216](https://github.com/googleapis/nodejs-datastore/issues/1216)) ([49c1462](https://github.com/googleapis/nodejs-datastore/commit/49c14626271c45473d73b07cda39a288017f1432)) + +## [8.3.0](https://github.com/googleapis/nodejs-datastore/compare/v8.2.2...v8.3.0) (2023-12-11) + + +### Features + +* Allow the user to set fallback to rest ([#1203](https://github.com/googleapis/nodejs-datastore/issues/1203)) ([8a1fa54](https://github.com/googleapis/nodejs-datastore/commit/8a1fa54e3873230256895c48b8b9c6889f75dd98)) + + +### Bug Fixes + +* Change tests to use new filter and use gax warn for warning just once ([#1185](https://github.com/googleapis/nodejs-datastore/issues/1185)) ([532711b](https://github.com/googleapis/nodejs-datastore/commit/532711bfd19b1a12844b02fd314f1703be4b0125)) +* **deps:** Update dependency sinon to v17 ([#1183](https://github.com/googleapis/nodejs-datastore/issues/1183)) ([52adb5e](https://github.com/googleapis/nodejs-datastore/commit/52adb5e13ddc123c2bed33df76be76760d33c06e)) + +## [8.2.2](https://github.com/googleapis/nodejs-datastore/compare/v8.2.1...v8.2.2) (2023-10-17) + + +### Bug Fixes + +* **deps:** Update google-gax ([#1173](https://github.com/googleapis/nodejs-datastore/issues/1173)) ([8237b15](https://github.com/googleapis/nodejs-datastore/commit/8237b152aa906cac55117cdeaf7a8bda85e94ac7)) + +## [8.2.1](https://github.com/googleapis/nodejs-datastore/compare/v8.2.0...v8.2.1) (2023-10-03) + + +### Bug Fixes + +* Make aggregation query requests run properly inside a transaction ([#1166](https://github.com/googleapis/nodejs-datastore/issues/1166)) ([263804b](https://github.com/googleapis/nodejs-datastore/commit/263804b768322de39bf87b4c5265c303a2bda173)) + +## [8.2.0](https://github.com/googleapis/nodejs-datastore/compare/v8.1.0...v8.2.0) (2023-10-02) + + +### Features + +* Support for using multiple databases in datastore ([#1090](https://github.com/googleapis/nodejs-datastore/issues/1090)) ([10ce563](https://github.com/googleapis/nodejs-datastore/commit/10ce563dae7e1164d3ee23a5887265c9de7b106f)) + + +### Bug Fixes + +* Allow users to set environment variable to connect to emulator running on docker ([#1164](https://github.com/googleapis/nodejs-datastore/issues/1164)) ([a41741b](https://github.com/googleapis/nodejs-datastore/commit/a41741b1412b1854aeecbe50441aa85015c3d399)) +* Check property existence for exclude from indexes with wildcard ([#1114](https://github.com/googleapis/nodejs-datastore/issues/1114)) ([e6b8ef7](https://github.com/googleapis/nodejs-datastore/commit/e6b8ef74ff10107943d0ae194f9a8d540d8557c1)) +* **deps:** Update dependency sinon to v16 ([#1150](https://github.com/googleapis/nodejs-datastore/issues/1150)) ([0d8b715](https://github.com/googleapis/nodejs-datastore/commit/0d8b7153fc156a4b55e965f39161bd5c19bffff6)) + +## [8.1.0](https://github.com/googleapis/nodejs-datastore/compare/v8.0.0...v8.1.0) (2023-09-07) + + +### Features + +* Sum and average aggregation queries ([#1097](https://github.com/googleapis/nodejs-datastore/issues/1097)) ([44ba6f8](https://github.com/googleapis/nodejs-datastore/commit/44ba6f8f84ef3e33aa1c07b0808a42bcf871b8c6)) + + +### Bug Fixes + +* Simplify logic for HTTP/1.1 REST fallback option ([#1138](https://github.com/googleapis/nodejs-datastore/issues/1138)) ([4cefaea](https://github.com/googleapis/nodejs-datastore/commit/4cefaeab2ee8af800303f09495883aa1a5a28632)) + +## [8.0.0](https://github.com/googleapis/nodejs-datastore/compare/v7.5.1...v8.0.0) (2023-08-09) + + +### ⚠ BREAKING CHANGES + +* upgrade to Node 14 + +### Miscellaneous Chores + +* Upgrade to Node 14 ([b7904f1](https://github.com/googleapis/nodejs-datastore/commit/b7904f12b1d398a5b0e6fefc2a002c404f9e7d3d)) + +## [7.5.1](https://github.com/googleapis/nodejs-datastore/compare/v7.5.0...v7.5.1) (2023-04-11) + + +### Bug Fixes + +* Allow user to set custom endpoints ([#1101](https://github.com/googleapis/nodejs-datastore/issues/1101)) ([e79fa49](https://github.com/googleapis/nodejs-datastore/commit/e79fa49f753984e34b63538005f29ab7efb7695e)) + +## [7.5.0](https://github.com/googleapis/nodejs-datastore/compare/v7.4.0...v7.5.0) (2023-03-29) + + +### Features + +* Add SUM/AVG aggregation query support in the preview branch and improve query API documentation ([#1094](https://github.com/googleapis/nodejs-datastore/issues/1094)) ([d14f87e](https://github.com/googleapis/nodejs-datastore/commit/d14f87ed4aaef42090673fbe78b23992093925ad)) + + +### Bug Fixes + +* Allow IN queries on __key__ ([#1085](https://github.com/googleapis/nodejs-datastore/issues/1085)) ([dd2d5f4](https://github.com/googleapis/nodejs-datastore/commit/dd2d5f4d15f714b3f3586250802fb6822b7e01ff)) + +## [7.4.0](https://github.com/googleapis/nodejs-datastore/compare/v7.3.2...v7.4.0) (2023-03-09) + + +### Features + +* Introduce EntityFilter class with support for and/or filters ([#1061](https://github.com/googleapis/nodejs-datastore/issues/1061)) ([8fc58c0](https://github.com/googleapis/nodejs-datastore/commit/8fc58c0f18e5333f996099e09ec673e9bf3460af)) + + +### Bug Fixes + +* Or filters with warnings ([#1075](https://github.com/googleapis/nodejs-datastore/issues/1075)) ([73bfcc4](https://github.com/googleapis/nodejs-datastore/commit/73bfcc40129309b512627f873d9f841f7ad370ee)) + +## [7.3.2](https://github.com/googleapis/nodejs-datastore/compare/v7.3.1...v7.3.2) (2023-02-17) + + +### Bug Fixes + +* Allow filtering null values ([#1067](https://github.com/googleapis/nodejs-datastore/issues/1067)) ([b89fa21](https://github.com/googleapis/nodejs-datastore/commit/b89fa211b366ec3e24ea5b2c8deeb90c695aa0df)) + +## [7.3.1](https://github.com/googleapis/nodejs-datastore/compare/v7.3.0...v7.3.1) (2023-02-17) + + +### Bug Fixes + +* **deps:** Roll back dependency @google-cloud/datastore to ^7.2.0 ([#1069](https://github.com/googleapis/nodejs-datastore/issues/1069)) ([1677c53](https://github.com/googleapis/nodejs-datastore/commit/1677c53b612799a90c455636ac19e081ff3730b3)) + +## [7.3.0](https://github.com/googleapis/nodejs-datastore/compare/v7.2.0...v7.3.0) (2023-02-16) + + +### Features + +* Add `OR` query support ([#1064](https://github.com/googleapis/nodejs-datastore/issues/1064)) ([196bdaf](https://github.com/googleapis/nodejs-datastore/commit/196bdafb27b6987ccbf547e480b008aee65775d0)) + +## [7.2.0](https://github.com/googleapis/nodejs-datastore/compare/v7.1.0...v7.2.0) (2023-02-09) + + +### Features + +* Add dynamic routing header annotation to DatastoreV1 ([b023ab4](https://github.com/googleapis/nodejs-datastore/commit/b023ab47146159c32ebc64dd09da681ad09c4081)) +* Added Snooze API support ([b023ab4](https://github.com/googleapis/nodejs-datastore/commit/b023ab47146159c32ebc64dd09da681ad09c4081)) +* Added SuggestConversationSummary RPC ([b023ab4](https://github.com/googleapis/nodejs-datastore/commit/b023ab47146159c32ebc64dd09da681ad09c4081)) +* New transaction options for datastoreV1 ([b023ab4](https://github.com/googleapis/nodejs-datastore/commit/b023ab47146159c32ebc64dd09da681ad09c4081)) + + +### Bug Fixes + +* **deps:** Update dependency sinon to v15 ([#1020](https://github.com/googleapis/nodejs-datastore/issues/1020)) ([a61258c](https://github.com/googleapis/nodejs-datastore/commit/a61258c92354df5a62cf6e7d6977f8f83bfd907f)) + +## [7.1.0](https://github.com/googleapis/nodejs-datastore/compare/v7.0.0...v7.1.0) (2023-01-18) + + +### Features + +* Add datastore aggregation query APIs ([#1008](https://github.com/googleapis/nodejs-datastore/issues/1008)) ([d5c2cb1](https://github.com/googleapis/nodejs-datastore/commit/d5c2cb1f0725f3cce1dde5b80ac7aff55b605f9a)) +* Add the count aggregate function ([#972](https://github.com/googleapis/nodejs-datastore/issues/972)) ([76adfc6](https://github.com/googleapis/nodejs-datastore/commit/76adfc6db03a4196999a8d510c0ab1ca15218f24)) +* Snapshot reads ([#963](https://github.com/googleapis/nodejs-datastore/issues/963)) ([0ecca86](https://github.com/googleapis/nodejs-datastore/commit/0ecca862fd93fc668a3dd3f5c93c54724e43f055)) +* Support regapic LRO ([#957](https://github.com/googleapis/nodejs-datastore/issues/957)) ([99778fb](https://github.com/googleapis/nodejs-datastore/commit/99778fb5e031eadd067b1ae9be0f910985966956)) + + +### Bug Fixes + +* Allow passing gax instance to client constructor ([#974](https://github.com/googleapis/nodejs-datastore/issues/974)) ([386b9c7](https://github.com/googleapis/nodejs-datastore/commit/386b9c735d57ce23f004ba3e9b1eb9a9377622dc)) +* Better support for fallback mode ([#967](https://github.com/googleapis/nodejs-datastore/issues/967)) ([0447d87](https://github.com/googleapis/nodejs-datastore/commit/0447d87ec162d64988d47e2fb21715dea78b6720)) +* Bring back LRO mixin ([#1009](https://github.com/googleapis/nodejs-datastore/issues/1009)) ([1d8de5f](https://github.com/googleapis/nodejs-datastore/commit/1d8de5f6bc5015dadd4be635748e799f05bfd325)) +* Change import long to require ([#968](https://github.com/googleapis/nodejs-datastore/issues/968)) ([5e710f2](https://github.com/googleapis/nodejs-datastore/commit/5e710f2c47001114ad087084507ad6d494143f1b)) +* **deps:** Update dependency @google-cloud/promisify to v3 ([#942](https://github.com/googleapis/nodejs-datastore/issues/942)) ([7b35856](https://github.com/googleapis/nodejs-datastore/commit/7b35856b0568571d5bcad70b2464344e6c06a4cb)) +* **deps:** Use google-gax v3.5.2 ([#1013](https://github.com/googleapis/nodejs-datastore/issues/1013)) ([1753eae](https://github.com/googleapis/nodejs-datastore/commit/1753eae467bff477e7991f74acbe3000656a955f)) +* Do not import the whole google-gax from proto JS ([#1553](https://github.com/googleapis/nodejs-datastore/issues/1553)) ([#973](https://github.com/googleapis/nodejs-datastore/issues/973)) ([9550bbc](https://github.com/googleapis/nodejs-datastore/commit/9550bbcc10912ca28b64a89153f3ae8e7862d939)) +* Preserve default values in x-goog-request-params header ([#979](https://github.com/googleapis/nodejs-datastore/issues/979)) ([2b80e1e](https://github.com/googleapis/nodejs-datastore/commit/2b80e1ef691a340ed15e3105983cd34983b57cb1)) +* Regenerated protos JS and TS definitions ([#1016](https://github.com/googleapis/nodejs-datastore/issues/1016)) ([d0ae656](https://github.com/googleapis/nodejs-datastore/commit/d0ae656ca83fbad0be5659d8d4516d8bde879a28)) +* Remove pip install statements ([#1546](https://github.com/googleapis/nodejs-datastore/issues/1546)) ([#970](https://github.com/googleapis/nodejs-datastore/issues/970)) ([2225fc7](https://github.com/googleapis/nodejs-datastore/commit/2225fc7753086243778c240a444c4940c29c5499)) +* Use google-gax v3.3.0 ([9550bbc](https://github.com/googleapis/nodejs-datastore/commit/9550bbcc10912ca28b64a89153f3ae8e7862d939)) + +## [7.0.0](https://github.com/googleapis/nodejs-datastore/compare/v6.6.2...v7.0.0) (2022-06-13) + + +### ⚠ BREAKING CHANGES + +* update library to use Node 12 (#945) + +### Features + +* add IN/NOT_IN/NOT_EQUALS support to cloud datastore proto ([6f22f0f](https://github.com/googleapis/nodejs-datastore/commit/6f22f0f473de8a5b07addc83523a6215e165563d)) +* define Datastore -> Firestore in Datastore mode migration long running operation metadata ([#907](https://github.com/googleapis/nodejs-datastore/issues/907)) ([652f66d](https://github.com/googleapis/nodejs-datastore/commit/652f66d2f88d80c900499890e7dd474cdbbc9c0b)) +* expose new read_time API fields, currently only available in private preview ([#932](https://github.com/googleapis/nodejs-datastore/issues/932)) ([aef00f8](https://github.com/googleapis/nodejs-datastore/commit/aef00f81864598fbd18b96dbf6986e3147d2a7a0)) +* Query filters for datastore ([#936](https://github.com/googleapis/nodejs-datastore/issues/936)) ([51725fa](https://github.com/googleapis/nodejs-datastore/commit/51725fab85cb1fcc231c71f6e8f56d58e958f676)) + + +### Bug Fixes + +* **deps:** update dependency sinon to v13 ([#918](https://github.com/googleapis/nodejs-datastore/issues/918)) ([fa01bd4](https://github.com/googleapis/nodejs-datastore/commit/fa01bd43ba1733a17411c071850c45de2b3ecd90)) +* **deps:** update dependency sinon to v14 ([#943](https://github.com/googleapis/nodejs-datastore/issues/943)) ([e117702](https://github.com/googleapis/nodejs-datastore/commit/e1177025eb3b6f2c6b1c20e3e83ad478c8eff366)) +* fixes for dynamic routing and streaming descriptors ([#947](https://github.com/googleapis/nodejs-datastore/issues/947)) ([ba6c190](https://github.com/googleapis/nodejs-datastore/commit/ba6c1902ba5ce19df651ed49d1d9a911c598fe5d)) + + +### Build System + +* update library to use Node 12 ([#945](https://github.com/googleapis/nodejs-datastore/issues/945)) ([eecf7ac](https://github.com/googleapis/nodejs-datastore/commit/eecf7ac37597ec4a84a1f4ceb9421764fddd1d0b)) + +### [6.6.2](https://www.github.com/googleapis/nodejs-datastore/compare/v6.6.1...v6.6.2) (2021-11-08) + + +### Bug Fixes + +* **cloud-rad:** move comments for TSDoc ([#896](https://www.github.com/googleapis/nodejs-datastore/issues/896)) ([2941f2f](https://www.github.com/googleapis/nodejs-datastore/commit/2941f2f0f132b41534e303d441d837051ce88fd7)) + +### [6.6.1](https://www.github.com/googleapis/nodejs-datastore/compare/v6.6.0...v6.6.1) (2021-11-04) + + +### Bug Fixes + +* **deps:** update dependency sinon to v12 ([#894](https://www.github.com/googleapis/nodejs-datastore/issues/894)) ([6010464](https://www.github.com/googleapis/nodejs-datastore/commit/60104649455aefdfba100a9e5c57543faf9278fb)) + +## [6.6.0](https://www.github.com/googleapis/nodejs-datastore/compare/v6.5.0...v6.6.0) (2021-10-13) + + +### Features + +* update retry and timeout logic for generated async/stream ([#883](https://www.github.com/googleapis/nodejs-datastore/issues/883)) ([cd3ae5c](https://www.github.com/googleapis/nodejs-datastore/commit/cd3ae5c12eddac3cc1149308c96cf9a8b0265e21)) + +## [6.5.0](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.8...v6.5.0) (2021-08-23) + + +### Features + +* turns on self-signed JWT feature flag ([#869](https://www.github.com/googleapis/nodejs-datastore/issues/869)) ([a42c88e](https://www.github.com/googleapis/nodejs-datastore/commit/a42c88e1b87ffcf38b1c45e94a846d1defb8fda2)) + +### [6.4.8](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.7...v6.4.8) (2021-08-17) + + +### Bug Fixes + +* **build:** migrate to using main branch ([#866](https://www.github.com/googleapis/nodejs-datastore/issues/866)) ([85844a4](https://www.github.com/googleapis/nodejs-datastore/commit/85844a4ff618fcb96c00802941d72135fc65bb98)) +* **deps:** google-gax v2.24.1 ([#868](https://www.github.com/googleapis/nodejs-datastore/issues/868)) ([1c0d40f](https://www.github.com/googleapis/nodejs-datastore/commit/1c0d40f27789d7f923b1a004d2b3589269969c93)) + +### [6.4.7](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.6...v6.4.7) (2021-07-26) + + +### Bug Fixes + +* drop dependency on pumpify ([#860](https://www.github.com/googleapis/nodejs-datastore/issues/860)) ([f3d4fd9](https://www.github.com/googleapis/nodejs-datastore/commit/f3d4fd97de3c90550977a096667088d063b51623)) + +### [6.4.6](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.5...v6.4.6) (2021-07-19) + + +### Bug Fixes + +* Updating WORKSPACE files to use the newest version of the Typescript generator. ([#855](https://www.github.com/googleapis/nodejs-datastore/issues/855)) ([1cdba8c](https://www.github.com/googleapis/nodejs-datastore/commit/1cdba8cc446b592170a8e404b24e09845524f50a)) + +### [6.4.5](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.4...v6.4.5) (2021-07-12) + + +### Bug Fixes + +* **deps:** google-gax v2.17.1 ([#853](https://www.github.com/googleapis/nodejs-datastore/issues/853)) ([67b47ce](https://www.github.com/googleapis/nodejs-datastore/commit/67b47cee28f317ea5e4a3e24bd4def2189496dff)) + +### [6.4.4](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.3...v6.4.4) (2021-06-30) + + +### Bug Fixes + +* **deps:** google-gax v2.17.0 with mTLS ([#849](https://www.github.com/googleapis/nodejs-datastore/issues/849)) ([76fa921](https://www.github.com/googleapis/nodejs-datastore/commit/76fa9217732060e2e408a49d9b6aaa7606ce13e6)) + +### [6.4.3](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.2...v6.4.3) (2021-06-30) + + +### Bug Fixes + +* Resolve getProjectId ([#848](https://www.github.com/googleapis/nodejs-datastore/issues/848)) ([9bfa885](https://www.github.com/googleapis/nodejs-datastore/commit/9bfa8857e832435112a38c8ab35f21d9054fbaa5)) + +### [6.4.2](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.1...v6.4.2) (2021-06-23) + + +### Bug Fixes + +* make request optional in all cases ([#843](https://www.github.com/googleapis/nodejs-datastore/issues/843)) ([d025627](https://www.github.com/googleapis/nodejs-datastore/commit/d0256278d1003a789c8b9ca082f923c5999b3257)) + +### [6.4.1](https://www.github.com/googleapis/nodejs-datastore/compare/v6.4.0...v6.4.1) (2021-06-10) + + +### Bug Fixes + +* **deps:** require google-gax v2.12.0 ([#825](https://www.github.com/googleapis/nodejs-datastore/issues/825)) ([0dee08a](https://www.github.com/googleapis/nodejs-datastore/commit/0dee08a912620c114ddfcf38a1d0636893f6f15a)) +* **deps:** update dependency sinon to v11 ([#832](https://www.github.com/googleapis/nodejs-datastore/issues/832)) ([d32610c](https://www.github.com/googleapis/nodejs-datastore/commit/d32610cdbe08151effc1a8d4b74540e68cbf4012)) + +## [6.4.0](https://www.github.com/googleapis/nodejs-datastore/compare/v6.3.1...v6.4.0) (2021-04-29) + + +### Features + +* Add createIndex, deleteIndex protos ([#797](https://www.github.com/googleapis/nodejs-datastore/issues/797)) ([3ff1f51](https://www.github.com/googleapis/nodejs-datastore/commit/3ff1f51f19297db94a370ec3fc9130f36e25ea70)) + + +### Bug Fixes + +* **deps:** update dependency sinon to v10 ([#810](https://www.github.com/googleapis/nodejs-datastore/issues/810)) ([267992f](https://www.github.com/googleapis/nodejs-datastore/commit/267992f4f1523fc5038715b009ebc697c5ca8255)) + +### [6.3.1](https://www.github.com/googleapis/nodejs-datastore/compare/v6.3.0...v6.3.1) (2020-11-25) + + +### Bug Fixes + +* **browser:** check for fetch on window ([#768](https://www.github.com/googleapis/nodejs-datastore/issues/768)) ([282dc99](https://www.github.com/googleapis/nodejs-datastore/commit/282dc99bd78ff086f57fca1a22ce530d44784dd7)) +* storing an empty Buffer ([#767](https://www.github.com/googleapis/nodejs-datastore/issues/767)) ([cf88927](https://www.github.com/googleapis/nodejs-datastore/commit/cf88927998ada76614fbe500c6e59e0d81c1b78b)) + +## [6.3.0](https://www.github.com/googleapis/nodejs-datastore/compare/v6.2.0...v6.3.0) (2020-11-09) + + +### Features + +* export Key and Entity ([#749](https://www.github.com/googleapis/nodejs-datastore/issues/749)) ([f4c8d0b](https://www.github.com/googleapis/nodejs-datastore/commit/f4c8d0b9cf172a39fbe9ce1906775418d16c1852)), closes [#568](https://www.github.com/googleapis/nodejs-datastore/issues/568) + + +### Bug Fixes + +* do not modify options object, use defaultScopes ([#751](https://www.github.com/googleapis/nodejs-datastore/issues/751)) ([07a77fe](https://www.github.com/googleapis/nodejs-datastore/commit/07a77fe0f69aecb378c965f403226b29fde57360)) + +## [6.2.0](https://www.github.com/googleapis/nodejs-datastore/compare/v6.1.1...v6.2.0) (2020-10-08) + + +### Features + +* introduce import/export + Index class ([#734](https://www.github.com/googleapis/nodejs-datastore/issues/734)) ([e329095](https://www.github.com/googleapis/nodejs-datastore/commit/e329095cb363989e11a1793a0b49ebcadd7a9093)) + +### [6.1.1](https://www.github.com/googleapis/nodejs-datastore/compare/v6.1.0...v6.1.1) (2020-09-12) + + +### Bug Fixes + +* split insert, update, upsert ([#693](https://www.github.com/googleapis/nodejs-datastore/issues/693)) ([fa5faac](https://www.github.com/googleapis/nodejs-datastore/commit/fa5faacb16b8c021314348acc5534e1802e0826e)) + +## [6.1.0](https://www.github.com/googleapis/nodejs-datastore/compare/v6.0.0...v6.1.0) (2020-07-06) + + +### Features + +* move ts target to es2018 from es2016 ([#677](https://www.github.com/googleapis/nodejs-datastore/issues/677)) ([e881610](https://www.github.com/googleapis/nodejs-datastore/commit/e8816109db9a9b8f3b7d079eb542954572847364)) +* **synth:** add datastore v1 admin api ([#686](https://www.github.com/googleapis/nodejs-datastore/issues/686)) ([25d6582](https://www.github.com/googleapis/nodejs-datastore/commit/25d6582911ad2596629565af3761a6756a6fd138)) + + +### Bug Fixes + +* null value while inserting in array ([#682](https://www.github.com/googleapis/nodejs-datastore/issues/682)) ([c60fe43](https://www.github.com/googleapis/nodejs-datastore/commit/c60fe437c8e3ce1bdebb191b5623b099bf43dc58)) +* proper fallback option handling ([#684](https://www.github.com/googleapis/nodejs-datastore/issues/684)) ([feba866](https://www.github.com/googleapis/nodejs-datastore/commit/feba866be528785e3b9048eb3cf0f67f121fd4ee)) + +## [6.0.0](https://www.github.com/googleapis/nodejs-datastore/compare/v5.1.0...v6.0.0) (2020-05-27) + + +### ⚠ BREAKING CHANGES + +* The `Datastore.projectId` property has been removed, and replaced with an asynchronous `getProjectid()` method. The projectId cannot be determined synchronously, so the previous approach was to use a `{{projectId}}` string placeholder if the projectId had not yet been acquired. This made it difficult to know exactly when the property would be defined. +* The library now supports Node.js v10+. The last version to support Node.js v8 is tagged legacy-8 on NPM. + +### Features + +* add async getProjectId method ([#657](https://www.github.com/googleapis/nodejs-datastore/issues/657)) ([2a7e034](https://www.github.com/googleapis/nodejs-datastore/commit/2a7e034e60f54100c5773d2d4dbe4dec6a721689)) +* add options param to query#runStream ([#611](https://www.github.com/googleapis/nodejs-datastore/issues/611)) ([7429c9d](https://www.github.com/googleapis/nodejs-datastore/commit/7429c9dbbdf4ed6715f04fa87cffec9bda8a97be)) +* drop node8 support ([#637](https://www.github.com/googleapis/nodejs-datastore/issues/637)) ([7ef38c1](https://www.github.com/googleapis/nodejs-datastore/commit/7ef38c1ade25f19f328290a3f69370676c80f021)) + + +### Bug Fixes + +* **deps:** update dependency @google-cloud/projectify to v2 ([#626](https://www.github.com/googleapis/nodejs-datastore/issues/626)) ([27fa23f](https://www.github.com/googleapis/nodejs-datastore/commit/27fa23fee0c0daa2e60ddd476aaad43877a05ea4)) +* **deps:** update dependency @google-cloud/promisify to v2 ([#625](https://www.github.com/googleapis/nodejs-datastore/issues/625)) ([1d64bc1](https://www.github.com/googleapis/nodejs-datastore/commit/1d64bc1bed7561bc93371cb7ca785fa1cc176f1f)) +* remove eslint, update gax, fix generated protos, run the generator ([#644](https://www.github.com/googleapis/nodejs-datastore/issues/644)) ([fcc5309](https://www.github.com/googleapis/nodejs-datastore/commit/fcc530933af25f1c40cfe0a7186a7e5f25a3f6bd)) +* **deps:** update dependency @grpc/grpc-js to v0.7.1 ([#615](https://www.github.com/googleapis/nodejs-datastore/issues/615)) ([3e83981](https://www.github.com/googleapis/nodejs-datastore/commit/3e83981f3da83143eb9b76f32e563683704f8d99)) +* identify propertyName ([#614](https://www.github.com/googleapis/nodejs-datastore/issues/614)) ([3635e13](https://www.github.com/googleapis/nodejs-datastore/commit/3635e138f3673eaff75ac30d25a2f21b3eecc5f9)) +* missing await in rollback ([#671](https://www.github.com/googleapis/nodejs-datastore/issues/671)) ([7cb353e](https://www.github.com/googleapis/nodejs-datastore/commit/7cb353e14e534a221e337f4ca2c30dd7ab01b469)) +* **deps:** update dependency @grpc/grpc-js to v0.7.4 ([#620](https://www.github.com/googleapis/nodejs-datastore/issues/620)) ([1d36be1](https://www.github.com/googleapis/nodejs-datastore/commit/1d36be1f11f4604f5c5170a06d7156e858a4748c)) +* **deps:** update dependency @grpc/grpc-js to v0.7.8 ([#638](https://www.github.com/googleapis/nodejs-datastore/issues/638)) ([a98ee1a](https://www.github.com/googleapis/nodejs-datastore/commit/a98ee1a9144415aef4788f7eb2b052c864f5370c)) +* regenerate files and fixed formatting, lint ([#664](https://www.github.com/googleapis/nodejs-datastore/issues/664)) ([34e9135](https://www.github.com/googleapis/nodejs-datastore/commit/34e91359aa7cd246799a651fa5f441ed8956b930)) +* support request params {key} with no =value ([#660](https://www.github.com/googleapis/nodejs-datastore/issues/660)) ([1faba1f](https://www.github.com/googleapis/nodejs-datastore/commit/1faba1f86fe31ff5898f897b640738987c55193d)) +* trim the dependency tree ([#651](https://www.github.com/googleapis/nodejs-datastore/issues/651)) ([1fd412e](https://www.github.com/googleapis/nodejs-datastore/commit/1fd412ef972c45ffefa96292c33389196a945338)) +* **deps:** update dependency @grpc/grpc-js to v0.7.9 ([#645](https://www.github.com/googleapis/nodejs-datastore/issues/645)) ([04b2ab2](https://www.github.com/googleapis/nodejs-datastore/commit/04b2ab29e9a0b4e4feef57641a5e5960a8bb88b8)) +* **deps:** update dependency google-auth-library to v6 ([#628](https://www.github.com/googleapis/nodejs-datastore/issues/628)) ([eb5f87b](https://www.github.com/googleapis/nodejs-datastore/commit/eb5f87b0037cad27b45653a0246a197ca4a0b33b)) + +## [5.1.0](https://www.github.com/googleapis/nodejs-datastore/compare/v5.0.6...v5.1.0) (2020-03-11) + + +### Features + +* add warning when int value is too large during upload ([#591](https://www.github.com/googleapis/nodejs-datastore/issues/591)) ([5a4821b](https://www.github.com/googleapis/nodejs-datastore/commit/5a4821b5fc8d283f168d3b52ac57021868e98679)) +* export protos in src/index.ts ([3fe21ab](https://www.github.com/googleapis/nodejs-datastore/commit/3fe21ab8835b4a9aad73659d7c6242d6cabb7f9f)) +* move library to Typescript code generation ([#608](https://www.github.com/googleapis/nodejs-datastore/issues/608)) ([d543aa6](https://www.github.com/googleapis/nodejs-datastore/commit/d543aa635764f9577bfced48c6a41c23f28771a0)) + + +### Bug Fixes + +* handle large int out of bounds error in streams ([#590](https://www.github.com/googleapis/nodejs-datastore/issues/590)) ([25b1fc2](https://www.github.com/googleapis/nodejs-datastore/commit/25b1fc2de4fddb5b68a9c6fbb5202e444746e69b)) +* **deps:** update dependency @grpc/grpc-js to v0.7.0 ([#613](https://www.github.com/googleapis/nodejs-datastore/issues/613)) ([8b5d391](https://www.github.com/googleapis/nodejs-datastore/commit/8b5d391e4cb80808b274f0992e275fd24177a750)) + +### [5.0.6](https://www.github.com/googleapis/nodejs-datastore/compare/v5.0.5...v5.0.6) (2020-02-20) + + +### Bug Fixes + +* **deps:** update dependency sinon to v9 ([#592](https://www.github.com/googleapis/nodejs-datastore/issues/592)) ([58c2b3f](https://www.github.com/googleapis/nodejs-datastore/commit/58c2b3fd97b1bab6bd6f03de0d7cdfba622bb6cb)) + +### [5.0.5](https://www.github.com/googleapis/nodejs-datastore/compare/v5.0.4...v5.0.5) (2020-02-12) + + +### Bug Fixes + +* **deps:** update dependency @grpc/grpc-js to v0.6.16 ([#585](https://www.github.com/googleapis/nodejs-datastore/issues/585)) ([f067258](https://www.github.com/googleapis/nodejs-datastore/commit/f067258a9b4e7b760235721561a999c656c2e076)) + +### [5.0.4](https://www.github.com/googleapis/nodejs-datastore/compare/v5.0.3...v5.0.4) (2020-01-29) + + +### Bug Fixes + +* enum, bytes, and Long types now accept strings ([86a48fa](https://www.github.com/googleapis/nodejs-datastore/commit/86a48fa60058216b2dec4e8c45fd74f9e77ff558)) + +### [5.0.3](https://www.github.com/googleapis/nodejs-datastore/compare/v5.0.2...v5.0.3) (2019-12-31) + + +### Bug Fixes + +* **deps:** update dependency @grpc/grpc-js to v0.6.15 ([#555](https://www.github.com/googleapis/nodejs-datastore/issues/555)) ([c015c1c](https://www.github.com/googleapis/nodejs-datastore/commit/c015c1c9142a7f3ad5cb26799fbd533aeae09b23)) +* **deps:** update dependency sinon to v8 ([#560](https://www.github.com/googleapis/nodejs-datastore/issues/560)) ([2d78de4](https://www.github.com/googleapis/nodejs-datastore/commit/2d78de40ab0866f773ea756b8e4b101ea8901b39)) + +### [5.0.2](https://www.github.com/googleapis/nodejs-datastore/compare/v5.0.1...v5.0.2) (2019-12-12) + + +### Bug Fixes + +* update datastore_transactional_single_entity_group_read_only to consistently use transaction ([#551](https://www.github.com/googleapis/nodejs-datastore/issues/551)) ([fbff2e7](https://www.github.com/googleapis/nodejs-datastore/commit/fbff2e7d2f054b157cc669c979a9e5acb09dd7a1)) +* **deps:** update dependency @grpc/grpc-js to v0.6.14 ([#552](https://www.github.com/googleapis/nodejs-datastore/issues/552)) ([f4df89c](https://www.github.com/googleapis/nodejs-datastore/commit/f4df89c50059541c75a7576c7264e3b7818871ea)) + +### [5.0.1](https://www.github.com/googleapis/nodejs-datastore/compare/v5.0.0...v5.0.1) (2019-12-05) + + +### Bug Fixes + +* **deps:** pin TypeScript below 3.7.0 ([eeebcf6](https://www.github.com/googleapis/nodejs-datastore/commit/eeebcf6d53fd4040b536fe3537d8a4c9a3bdd5c3)) +* **deps:** update dependency @grpc/grpc-js to v0.6.12 ([#541](https://www.github.com/googleapis/nodejs-datastore/issues/541)) ([972d3e7](https://www.github.com/googleapis/nodejs-datastore/commit/972d3e7e37b161ca8404975e4f9f80887609268f)) +* **deps:** update dependency @grpc/grpc-js to v0.6.13 ([#548](https://www.github.com/googleapis/nodejs-datastore/issues/548)) ([f8948c6](https://www.github.com/googleapis/nodejs-datastore/commit/f8948c63924225866130eb81e7ed26becbc3e1a9)) + +## [5.0.0](https://www.github.com/googleapis/nodejs-datastore/compare/v4.5.2...v5.0.0) (2019-11-14) + + +### ⚠ BREAKING CHANGES + +* keyToLegacyUrlsafe is now an async method (#496) +* throw error with out of bounds integer values, optionally wrap into DsInt or provide a custom 'integerValue' type cast options #516 + +### Features + +* throw error with out of bounds integer values, optionally wrap into DsInt or provide a custom 'integerValue' type cast options [#516](https://www.github.com/googleapis/nodejs-datastore/issues/516) ([6c8cc74](https://www.github.com/googleapis/nodejs-datastore/commit/6c8cc74820ca7eaab0e08b9cefac11095c466256)) + + +### Bug Fixes + +* **docs:** snippets are now replaced in jsdoc comments ([#535](https://www.github.com/googleapis/nodejs-datastore/issues/535)) ([53ddc21](https://www.github.com/googleapis/nodejs-datastore/commit/53ddc21f3b1545e660433b3805948dfc862ba792)) +* keyToLegacyUrlsafe is now an async method ([#496](https://www.github.com/googleapis/nodejs-datastore/issues/496)) ([bbd1ebe](https://www.github.com/googleapis/nodejs-datastore/commit/bbd1ebe82e302155b80ac801f892a7f12ad17e13)) + +### [4.5.2](https://www.github.com/googleapis/nodejs-datastore/compare/v4.5.1...v4.5.2) (2019-11-08) + + +### Bug Fixes + +* **deps:** update dependency @grpc/grpc-js to v0.6.11 ([#532](https://www.github.com/googleapis/nodejs-datastore/issues/532)) ([95cded0](https://www.github.com/googleapis/nodejs-datastore/commit/95cded0d9ec365dc091bb0182ea8fe142d93cd64)) + +### [4.5.1](https://www.github.com/googleapis/nodejs-datastore/compare/v4.5.0...v4.5.1) (2019-11-07) + + +### Bug Fixes + +* **deps:** update dependency @grpc/grpc-js to v0.6.10 ([#527](https://www.github.com/googleapis/nodejs-datastore/issues/527)) ([beb3bcc](https://www.github.com/googleapis/nodejs-datastore/commit/beb3bcc92fd6f3a09d970cb4d66cbb04dae06353)) + +## [4.5.0](https://www.github.com/googleapis/nodejs-datastore/compare/v4.4.1...v4.5.0) (2019-11-04) + + +### Features + +* support DSInt / DSDouble recognition from JSON ([#480](https://www.github.com/googleapis/nodejs-datastore/issues/480)) ([9f2fb3c](https://www.github.com/googleapis/nodejs-datastore/commit/9f2fb3cf6fa0672ef2bc252c0765dd84dbbc977a)) + + +### Bug Fixes + +* **types:** removed duplicate declaration ([#524](https://www.github.com/googleapis/nodejs-datastore/issues/524)) ([26cbb67](https://www.github.com/googleapis/nodejs-datastore/commit/26cbb67dd9d81900960363e20a9df545ba0c5675)) +* upgrade and pin to @grpc/grpc-js@0.6.9 ([#526](https://www.github.com/googleapis/nodejs-datastore/issues/526)) ([3b85eab](https://www.github.com/googleapis/nodejs-datastore/commit/3b85eabec858c98f16edd5f04416495f248fc68a)) + +### [4.4.1](https://www.github.com/googleapis/nodejs-datastore/compare/v4.4.0...v4.4.1) (2019-10-22) + + +### Bug Fixes + +* **deps:** bump google-gax to 1.7.5 ([#518](https://www.github.com/googleapis/nodejs-datastore/issues/518)) ([3bb56c1](https://www.github.com/googleapis/nodejs-datastore/commit/3bb56c15462892d7afcc0ca3be7064cfd1cec745)) + +## [4.4.0](https://www.github.com/googleapis/nodejs-datastore/compare/v4.3.0...v4.4.0) (2019-10-09) + + +### Bug Fixes + +* transaction#run overloads' param types correction ([#501](https://www.github.com/googleapis/nodejs-datastore/issues/501)) ([c88e66e](https://www.github.com/googleapis/nodejs-datastore/commit/c88e66e)) +* **deps:** update dependency @grpc/grpc-js to ^0.6.0 ([#503](https://www.github.com/googleapis/nodejs-datastore/issues/503)) ([7c3c213](https://www.github.com/googleapis/nodejs-datastore/commit/7c3c213)) +* use compatible version of google-gax ([567e9dd](https://www.github.com/googleapis/nodejs-datastore/commit/567e9dd)) + + +### Features + +* .d.ts for protos ([#506](https://www.github.com/googleapis/nodejs-datastore/issues/506)) ([869e673](https://www.github.com/googleapis/nodejs-datastore/commit/869e673)) +* add merge method for merging an object into an existing entity ([#452](https://www.github.com/googleapis/nodejs-datastore/issues/452)) ([8e026af](https://www.github.com/googleapis/nodejs-datastore/commit/8e026af)) + +## [4.3.0](https://www.github.com/googleapis/nodejs-datastore/compare/v4.2.0...v4.3.0) (2019-09-12) + + +### Bug Fixes + +* **types:** fix and clean up types for request.ts ([#472](https://www.github.com/googleapis/nodejs-datastore/issues/472)) ([928f237](https://www.github.com/googleapis/nodejs-datastore/commit/928f237)) +* added overload method for transaction.createQuery to handle namespace issue ([#486](https://www.github.com/googleapis/nodejs-datastore/issues/486)) ([28568c1](https://www.github.com/googleapis/nodejs-datastore/commit/28568c1)) +* emit encoding errors on user stream ([#492](https://www.github.com/googleapis/nodejs-datastore/issues/492)) ([8d3b552](https://www.github.com/googleapis/nodejs-datastore/commit/8d3b552)) +* refactor and clean up types ([#476](https://www.github.com/googleapis/nodejs-datastore/issues/476)) ([5971c4a](https://www.github.com/googleapis/nodejs-datastore/commit/5971c4a)) +* update node version in HTTP headers ([#475](https://www.github.com/googleapis/nodejs-datastore/issues/475)) ([b6e65bb](https://www.github.com/googleapis/nodejs-datastore/commit/b6e65bb)) + + +### Features + +* add support for auto-unindex ([#453](https://www.github.com/googleapis/nodejs-datastore/issues/453)) ([33292d2](https://www.github.com/googleapis/nodejs-datastore/commit/33292d2)) +* load protos from JSON, grpc-fallback support ([#485](https://www.github.com/googleapis/nodejs-datastore/issues/485)) ([1cf85ea](https://www.github.com/googleapis/nodejs-datastore/commit/1cf85ea)) +* support key re-use from serialized path ([#474](https://www.github.com/googleapis/nodejs-datastore/issues/474)) ([b36c90f](https://www.github.com/googleapis/nodejs-datastore/commit/b36c90f)) + +## [4.2.0](https://www.github.com/googleapis/nodejs-datastore/compare/v4.1.4...v4.2.0) (2019-08-09) + + +### Bug Fixes + +* **deps:** update dependency @grpc/grpc-js to ^0.5.0 ([#461](https://www.github.com/googleapis/nodejs-datastore/issues/461)) ([1850f25](https://www.github.com/googleapis/nodejs-datastore/commit/1850f25)) +* **deps:** update dependency google-auth-library to v5 ([#462](https://www.github.com/googleapis/nodejs-datastore/issues/462)) ([1f97053](https://www.github.com/googleapis/nodejs-datastore/commit/1f97053)) +* **types:** correct type of Datastore.KEY ([#459](https://www.github.com/googleapis/nodejs-datastore/issues/459)) ([09def6d](https://www.github.com/googleapis/nodejs-datastore/commit/09def6d)) +* allow calls with no request, add JSON proto ([771b634](https://www.github.com/googleapis/nodejs-datastore/commit/771b634)) + + +### Features + +* add support for appengine legacy url encoding ([#456](https://www.github.com/googleapis/nodejs-datastore/issues/456)) ([357a9cf](https://www.github.com/googleapis/nodejs-datastore/commit/357a9cf)) +* excludeFromIndex allow for '*' wildcard to catch all properties on object ([#451](https://www.github.com/googleapis/nodejs-datastore/issues/451)) ([215cbee](https://www.github.com/googleapis/nodejs-datastore/commit/215cbee)) + +### [4.1.4](https://www.github.com/googleapis/nodejs-datastore/compare/v4.1.3...v4.1.4) (2019-07-23) + + +### Bug Fixes + +* **deps:** drop dependency on through2 ([#457](https://www.github.com/googleapis/nodejs-datastore/issues/457)) ([e57ed63](https://www.github.com/googleapis/nodejs-datastore/commit/e57ed63)) + +### [4.1.3](https://www.github.com/googleapis/nodejs-datastore/compare/v4.1.2...v4.1.3) (2019-06-27) + + +### Bug Fixes + +* **docs:** link to reference docs section on googleapis.dev ([#444](https://www.github.com/googleapis/nodejs-datastore/issues/444)) ([0fd5492](https://www.github.com/googleapis/nodejs-datastore/commit/0fd5492)) +* **typescript:** grpc->[@grpc-js](https://www.github.com/grpc-js) ([#446](https://www.github.com/googleapis/nodejs-datastore/issues/446)) ([d8a8c81](https://www.github.com/googleapis/nodejs-datastore/commit/d8a8c81)) +* **typescript:** query pojection -> projection ([#445](https://www.github.com/googleapis/nodejs-datastore/issues/445)) ([32b6311](https://www.github.com/googleapis/nodejs-datastore/commit/32b6311)) + +### [4.1.2](https://www.github.com/googleapis/nodejs-datastore/compare/v4.1.1...v4.1.2) (2019-06-20) + + +### Bug Fixes + +* **docs:** fix tag rendering in Key doc ([#439](https://www.github.com/googleapis/nodejs-datastore/issues/439)) ([2edd95c](https://www.github.com/googleapis/nodejs-datastore/commit/2edd95c)) +* **docs:** move to new client docs URL ([#437](https://www.github.com/googleapis/nodejs-datastore/issues/437)) ([278c1c5](https://www.github.com/googleapis/nodejs-datastore/commit/278c1c5)) +* add `parseInt` to constructor of task keys ([#436](https://www.github.com/googleapis/nodejs-datastore/issues/436)) ([7ee76b3](https://www.github.com/googleapis/nodejs-datastore/commit/7ee76b3)) +* assign more restrictive type to PathType ([#433](https://www.github.com/googleapis/nodejs-datastore/issues/433)) ([#435](https://www.github.com/googleapis/nodejs-datastore/issues/435)) ([a93ef91](https://www.github.com/googleapis/nodejs-datastore/commit/a93ef91)) + +### [4.1.1](https://www.github.com/googleapis/nodejs-datastore/compare/v4.1.0...v4.1.1) (2019-06-11) + + +### Bug Fixes + +* added legacy samples back, until we can update external references ([#428](https://www.github.com/googleapis/nodejs-datastore/issues/428)) ([c282ff7](https://www.github.com/googleapis/nodejs-datastore/commit/c282ff7)) +* **docs:** link to up-to-date googleapis.dev doc site ([#431](https://www.github.com/googleapis/nodejs-datastore/issues/431)) ([58d41a5](https://www.github.com/googleapis/nodejs-datastore/commit/58d41a5)) + +## [4.1.0](https://www.github.com/googleapis/nodejs-datastore/compare/v4.0.0...v4.1.0) (2019-06-05) + + +### Bug Fixes + +* default options to empty object ([c04777d](https://www.github.com/googleapis/nodejs-datastore/commit/c04777d)) + + +### Features + +* support apiEndpoint override in client constructor ([#422](https://www.github.com/googleapis/nodejs-datastore/issues/422)) ([0f75d38](https://www.github.com/googleapis/nodejs-datastore/commit/0f75d38)) + +## [4.0.0](https://www.github.com/googleapis/nodejs-datastore/compare/v3.1.2...v4.0.0) (2019-05-15) + + +### Bug Fixes + +* **deps:** update dependency google-gax to v1 ([#402](https://www.github.com/googleapis/nodejs-datastore/issues/402)) ([547f1a1](https://www.github.com/googleapis/nodejs-datastore/commit/547f1a1)) +* correct Long types import ([#358](https://www.github.com/googleapis/nodejs-datastore/issues/358)) ([dfe1def](https://www.github.com/googleapis/nodejs-datastore/commit/dfe1def)) +* DEADLINE_EXCEEDED is no longer retried ([47eedf0](https://www.github.com/googleapis/nodejs-datastore/commit/47eedf0)) +* DEADLINE_EXCEEDED retry code is idempotent ([#403](https://www.github.com/googleapis/nodejs-datastore/issues/403)) ([2a7c3ab](https://www.github.com/googleapis/nodejs-datastore/commit/2a7c3ab)) +* **deps:** update dependency @google-cloud/projectify to v1 ([#391](https://www.github.com/googleapis/nodejs-datastore/issues/391)) ([761896b](https://www.github.com/googleapis/nodejs-datastore/commit/761896b)) +* **deps:** update dependency @google-cloud/promisify to v1 ([#392](https://www.github.com/googleapis/nodejs-datastore/issues/392)) ([94a45bd](https://www.github.com/googleapis/nodejs-datastore/commit/94a45bd)) +* **deps:** update dependency arrify to v2 ([2b47d10](https://www.github.com/googleapis/nodejs-datastore/commit/2b47d10)) +* **deps:** update dependency google-auth-library to v4 ([#400](https://www.github.com/googleapis/nodejs-datastore/issues/400)) ([19bc787](https://www.github.com/googleapis/nodejs-datastore/commit/19bc787)) +* **deps:** update dependency google-gax to ^0.26.0 ([#386](https://www.github.com/googleapis/nodejs-datastore/issues/386)) ([29b81e3](https://www.github.com/googleapis/nodejs-datastore/commit/29b81e3)) +* include 'x-goog-request-params' header in requests ([#372](https://www.github.com/googleapis/nodejs-datastore/issues/372)) ([d91be05](https://www.github.com/googleapis/nodejs-datastore/commit/d91be05)) +* lint ([#384](https://www.github.com/googleapis/nodejs-datastore/issues/384)) ([9a4d746](https://www.github.com/googleapis/nodejs-datastore/commit/9a4d746)) +* **docs:** move ts overloads above doc string ([#356](https://www.github.com/googleapis/nodejs-datastore/issues/356)) ([a7f1123](https://www.github.com/googleapis/nodejs-datastore/commit/a7f1123)) + + +### Build System + +* upgrade engines field to >=8.10.0 ([#388](https://www.github.com/googleapis/nodejs-datastore/issues/388)) ([a8cf59f](https://www.github.com/googleapis/nodejs-datastore/commit/a8cf59f)) + + +### BREAKING CHANGES + +* upgrade engines field to >=8.10.0 (#388) + +## v3.1.2 + +03-06-2019 12:24 PST + +### Bug fixes +- fix: make an explicit dependency on long ([#352](https://github.com/googleapis/nodejs-datastore/pull/352)) +- fix: include types in package ([#351](https://github.com/googleapis/nodejs-datastore/pull/351)) +- fix: add missing package, and add install test ([#346](https://github.com/googleapis/nodejs-datastore/pull/346)) + +### Documentation +- docs(samples): Update datastore_transaction_retry sample to use function arguments rather than closed variables. ([#339](https://github.com/googleapis/nodejs-datastore/pull/339)) + +### Internal / Testing Changes +- refactor(ts): enable noImplicitAny on test/request.ts ([#343](https://github.com/googleapis/nodejs-datastore/pull/343)) +- refactor(ts): enable noImplicitAny on test/query.ts ([#342](https://github.com/googleapis/nodejs-datastore/pull/342)) +- build: update release configuration +- chore: update proto docs and code style +- chore(deps): update dependency mocha to v6 ([#338](https://github.com/googleapis/nodejs-datastore/pull/338)) + +## v3.1.1 + +02-18-2019 22:46 PST + +### Bug fixes +- fix: include proto d.ts in the build ([#335](https://github.com/googleapis/nodejs-datastore/pull/335)) +- fix(deps): update dependency @google-cloud/promisify to ^0.4.0 ([#333](https://github.com/googleapis/nodejs-datastore/pull/333)) +- fix: throw on invalid credentials ([#331](https://github.com/googleapis/nodejs-datastore/pull/331)) +- fix(deps): update dependency yargs to v13 ([#329](https://github.com/googleapis/nodejs-datastore/pull/329)) + +### Documentation +- build: use linkinator for docs test ([#332](https://github.com/googleapis/nodejs-datastore/pull/332)) +- docs: update links in contrib guide ([#334](https://github.com/googleapis/nodejs-datastore/pull/334)) + +## v3.1.0 + +02-09-2019 17:57 PST + +This one's coming hot with fresh new TypeScript types 🔥 + +### New Features +- feat: typings for gapic files ([#307](https://github.com/googleapis/nodejs-datastore/pull/307)) + +### Bug fixes +- fix(types): Make gaxOptions optional in Transaction.rollback() ([#310](https://github.com/googleapis/nodejs-datastore/pull/310)) + +### Dependencies +- fix(deps): update dependency google-auth-library to v3 ([#302](https://github.com/googleapis/nodejs-datastore/pull/302)) +- fix(deps): update dependency google-gax to ^0.25.0 ([#316](https://github.com/googleapis/nodejs-datastore/pull/316)) +- fix(deps): update dependency google-gax to ^0.24.0 ([#312](https://github.com/googleapis/nodejs-datastore/pull/312)) + +### Documentation +- docs: update contributing path in README ([#322](https://github.com/googleapis/nodejs-datastore/pull/322)) +- chore: move CONTRIBUTING.md to root ([#321](https://github.com/googleapis/nodejs-datastore/pull/321)) +- docs: add lint/fix example to contributing guide ([#319](https://github.com/googleapis/nodejs-datastore/pull/319)) +- docs(samples): Update Datastore snippet for read only transaction +- docs(key): copy Datastore#key examples to Key ctor ([#306](https://github.com/googleapis/nodejs-datastore/pull/306)) + +### Internal / Testing Changes +- refactor: clean up types for tests ([#325](https://github.com/googleapis/nodejs-datastore/pull/325)) +- refactor: asyncify the system test ([#324](https://github.com/googleapis/nodejs-datastore/pull/324)) +- build: test using @grpc/grpc-js in CI ([#323](https://github.com/googleapis/nodejs-datastore/pull/323)) +- refactor(types): enable noImplicitAny for transaction.ts & request.ts ([#305](https://github.com/googleapis/nodejs-datastore/pull/305)) +- chore(deps): update dependency eslint-config-prettier to v4 ([#313](https://github.com/googleapis/nodejs-datastore/pull/313)) +- build: ignore googleapis.com in doc link check ([#311](https://github.com/googleapis/nodejs-datastore/pull/311)) +- chore: update year in the license headers. ([#304](https://github.com/googleapis/nodejs-datastore/pull/304)) + +## v3.0.1 + +01-15-2019 13:20 PST + +### Bug fixes +- fix: ship the build directory ([#300](https://github.com/googleapis/nodejs-datastore/pull/300)) + +### Internal / Testing Changes +- build: check broken links in generated docs ([#292](https://github.com/googleapis/nodejs-datastore/pull/292)) + +## v3.0.0 + +01-14-2019 20:31 PST + +**This release has breaking changes!** The import style of this library has changed to be consistent with [es modules](https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/). + +#### Old busted code +```js +const Datastore = require('@google-cloud/datastore')(); +// or... +const Datastore = require('@google-cloud/datastore'); +const ds = new Datastore(); +``` + +#### New hot code +```js +const {Datastore} = require('@google-cloud/datastore'); +const ds = new Datastore(); +``` + +Please take care to update your imports accordingly! + +### Dependencies +- fix(deps): update dependency google-gax to ^0.23.0 ([#296](https://github.com/googleapis/nodejs-datastore/pull/296)) +- fix(deps): update dependency google-gax to ^0.22.0 ([#248](https://github.com/googleapis/nodejs-datastore/pull/248)) +- fix(deps): update dependency concat-stream to v2 ([#290](https://github.com/googleapis/nodejs-datastore/pull/290)) +- refactor: remove async module usage ([#272](https://github.com/googleapis/nodejs-datastore/pull/272)) +- fix(deps): update dependency through2 to v3 ([#237](https://github.com/googleapis/nodejs-datastore/pull/237)) +- chore: remove unused dependencies ([#226](https://github.com/googleapis/nodejs-datastore/pull/226)) +- fix(deps): update dependency google-proto-files to ^0.17.0 ([#210](https://github.com/googleapis/nodejs-datastore/pull/210)) + +### Documentation +- fix(docs): fix namespace causing 404s ([#294](https://github.com/googleapis/nodejs-datastore/pull/294)) +- fix(docs): remove unused long running operations types +- docs: Update doc comment showing structure of entity ([#276](https://github.com/googleapis/nodejs-datastore/pull/276)) +- docs: update readme badges ([#269](https://github.com/googleapis/nodejs-datastore/pull/269)) +- refactor(samples): Samples to use async/await +- docs: update auto-generated jsdoc comments ([#245](https://github.com/googleapis/nodejs-datastore/pull/245)) + +### Internal / Testing Changes +- refactor: sprinkle some types about ([#291](https://github.com/googleapis/nodejs-datastore/pull/291)) +- chore(deps): update dependency @types/sinon to v7.0.2 ([#289](https://github.com/googleapis/nodejs-datastore/pull/289)) +- chore(deps): update dependency @types/sinon to v7 ([#286](https://github.com/googleapis/nodejs-datastore/pull/286)) +- refactor(ts): enable lint and fix ([#287](https://github.com/googleapis/nodejs-datastore/pull/287)) +- chore(build): inject yoshi automation key ([#285](https://github.com/googleapis/nodejs-datastore/pull/285)) +- chore: update nyc and eslint configs ([#284](https://github.com/googleapis/nodejs-datastore/pull/284)) +- chore: fix publish.sh permission +x ([#282](https://github.com/googleapis/nodejs-datastore/pull/282)) +- fix(build): fix Kokoro release script ([#281](https://github.com/googleapis/nodejs-datastore/pull/281)) +- build: add Kokoro configs for autorelease ([#280](https://github.com/googleapis/nodejs-datastore/pull/280)) +- chore: always nyc report before calling codecov ([#275](https://github.com/googleapis/nodejs-datastore/pull/275)) +- chore: nyc ignore build/test by default ([#274](https://github.com/googleapis/nodejs-datastore/pull/274)) +- chore: update license file ([#271](https://github.com/googleapis/nodejs-datastore/pull/271)) +- refactor: run gts fix ([#265](https://github.com/googleapis/nodejs-datastore/pull/265)) +- chore(deps): update dependency typescript to ~3.2.0 ([#264](https://github.com/googleapis/nodejs-datastore/pull/264)) +- fix(build): fix system key decryption ([#266](https://github.com/googleapis/nodejs-datastore/pull/266)) +- refactor(samples): convert sample tests from ava to mocha ([#259](https://github.com/googleapis/nodejs-datastore/pull/259)) +- fix: Pin @types/sinon to last compatible version ([#256](https://github.com/googleapis/nodejs-datastore/pull/256)) +- chore: add synth.metadata ([#254](https://github.com/googleapis/nodejs-datastore/pull/254)) +- refactor(ts): enable noImplicitThis ([#250](https://github.com/googleapis/nodejs-datastore/pull/250)) +- chore(deps): update dependency gts to ^0.9.0 ([#247](https://github.com/googleapis/nodejs-datastore/pull/247)) +- chore: update eslintignore config ([#246](https://github.com/googleapis/nodejs-datastore/pull/246)) +- refactor(ts): use es module imports ([#244](https://github.com/googleapis/nodejs-datastore/pull/244)) +- chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 ([#243](https://github.com/googleapis/nodejs-datastore/pull/243)) +- chore: drop contributors from multiple places ([#241](https://github.com/googleapis/nodejs-datastore/pull/241)) +- chore(deps): update dependency @types/is to v0.0.21 ([#240](https://github.com/googleapis/nodejs-datastore/pull/240)) +- chore: use latest npm on Windows ([#239](https://github.com/googleapis/nodejs-datastore/pull/239)) +- refactor(ts): convert to typescript ([#236](https://github.com/googleapis/nodejs-datastore/pull/236)) +- chore: update CircleCI config ([#235](https://github.com/googleapis/nodejs-datastore/pull/235)) +- chore: include build in eslintignore ([#232](https://github.com/googleapis/nodejs-datastore/pull/232)) +- chore(deps): update dependency eslint-plugin-node to v8 ([#227](https://github.com/googleapis/nodejs-datastore/pull/227)) +- chore: update issue templates ([#225](https://github.com/googleapis/nodejs-datastore/pull/225)) +- chore: remove old issue template ([#223](https://github.com/googleapis/nodejs-datastore/pull/223)) +- build: run tests on node11 ([#222](https://github.com/googleapis/nodejs-datastore/pull/222)) +- chores(build): do not collect sponge.xml from windows builds ([#221](https://github.com/googleapis/nodejs-datastore/pull/221)) +- chores(build): run codecov on continuous builds ([#220](https://github.com/googleapis/nodejs-datastore/pull/220)) +- chore: update new issue template ([#219](https://github.com/googleapis/nodejs-datastore/pull/219)) +- build: fix codecov uploading on Kokoro ([#213](https://github.com/googleapis/nodejs-datastore/pull/213)) +- fix(deps): update dependency sinon to v7 ([#212](https://github.com/googleapis/nodejs-datastore/pull/212)) +- Update kokoro config ([#207](https://github.com/googleapis/nodejs-datastore/pull/207)) +- chore(deps): update dependency eslint-plugin-prettier to v3 ([#206](https://github.com/googleapis/nodejs-datastore/pull/206)) + +## v2.0.0 + +### Breaking Changes +- chore: really delete node4 and node9 ([#131](https://github.com/googleapis/nodejs-datastore/pull/131)) +- fix: drop support for node.js 4.x and 9.x ([#129](https://github.com/googleapis/nodejs-datastore/pull/129)) + +### Dependencies +- fix(deps): update dependency google-gax to ^0.20.0 ([#194](https://github.com/googleapis/nodejs-datastore/pull/194)) +- fix(deps): update dependency google-auth-library to v2 ([#184](https://github.com/googleapis/nodejs-datastore/pull/184)) +- fix(deps): update dependency google-gax to ^0.19.0 ([#177](https://github.com/googleapis/nodejs-datastore/pull/177)) +- chore: remove safe-buffer ([#144](https://github.com/googleapis/nodejs-datastore/pull/144)) +- fix(deps): update dependency google-gax to ^0.18.0 ([#154](https://github.com/googleapis/nodejs-datastore/pull/154)) +- chore: drop dependency on common ([#148](https://github.com/googleapis/nodejs-datastore/pull/148)) +- chore: remove propprop ([#145](https://github.com/googleapis/nodejs-datastore/pull/145)) +- refactor: update nodejs-common and google-auth-library ([#112](https://github.com/googleapis/nodejs-datastore/pull/112)) + +### Documentation +- doc: fix namespace causing 404 ([#170](https://github.com/googleapis/nodejs-datastore/pull/170)) + +### Internal / Testing Changes +- build: prevent system/sample-test from leaking credentials +- Update CI config ([#201](https://github.com/googleapis/nodejs-datastore/pull/201)) +- test: remove appveyor config ([#200](https://github.com/googleapis/nodejs-datastore/pull/200)) +- Update the kokoro config ([#199](https://github.com/googleapis/nodejs-datastore/pull/199)) +- Enable prefer-const in the eslint config ([#197](https://github.com/googleapis/nodejs-datastore/pull/197)) +- Enable no-var in eslint ([#196](https://github.com/googleapis/nodejs-datastore/pull/196)) +- Switch to let/const ([#195](https://github.com/googleapis/nodejs-datastore/pull/195)) +- Update CI config ([#193](https://github.com/googleapis/nodejs-datastore/pull/193)) +- Retry npm install in CI ([#191](https://github.com/googleapis/nodejs-datastore/pull/191)) +- Update CI config ([#185](https://github.com/googleapis/nodejs-datastore/pull/185)) +- Update CI config ([#182](https://github.com/googleapis/nodejs-datastore/pull/182)) +- chore(deps): update dependency nyc to v13 ([#181](https://github.com/googleapis/nodejs-datastore/pull/181)) +- Update the CI config ([#180](https://github.com/googleapis/nodejs-datastore/pull/180)) +- chore: use arrow functions ([#176](https://github.com/googleapis/nodejs-datastore/pull/176)) +- chore: make CircleCI config consistent ([#178](https://github.com/googleapis/nodejs-datastore/pull/178)) +- chore: start converting to es classes ([#173](https://github.com/googleapis/nodejs-datastore/pull/173)) +- chore(deps): update dependency eslint-config-prettier to v3 ([#169](https://github.com/googleapis/nodejs-datastore/pull/169)) +- test: use sinon for mocking ([#168](https://github.com/googleapis/nodejs-datastore/pull/168)) +- chore: do not use npm ci ([#166](https://github.com/googleapis/nodejs-datastore/pull/166)) +- fix: fix the samples tests ([#164](https://github.com/googleapis/nodejs-datastore/pull/164)) +- chore: ignore package-lock.json ([#162](https://github.com/googleapis/nodejs-datastore/pull/162)) +- chore(deps): lock file maintenance ([#160](https://github.com/googleapis/nodejs-datastore/pull/160)) +- chore: switch back to auto-generated code +- chore(deps): lock file maintenance ([#159](https://github.com/googleapis/nodejs-datastore/pull/159)) +- chore: use let and const ([#158](https://github.com/googleapis/nodejs-datastore/pull/158)) +- chore: update renovate config ([#157](https://github.com/googleapis/nodejs-datastore/pull/157)) +- Delete reference to non-existent sample. ([#149](https://github.com/googleapis/nodejs-datastore/pull/149)) +- test: throw on deprecation ([#155](https://github.com/googleapis/nodejs-datastore/pull/155)) +- chore: move mocha options to mocha.opts ([#150](https://github.com/googleapis/nodejs-datastore/pull/150)) +- Update CI config ([#151](https://github.com/googleapis/nodejs-datastore/pull/151)) +- chore: add node templates to synth.py ([#143](https://github.com/googleapis/nodejs-datastore/pull/143)) +- chore: please eslint ([#146](https://github.com/googleapis/nodejs-datastore/pull/146)) +- chore(deps): lock file maintenance ([#142](https://github.com/googleapis/nodejs-datastore/pull/142)) +- chore(deps): update dependency eslint-plugin-node to v7 ([#139](https://github.com/googleapis/nodejs-datastore/pull/139)) +- test: use strictEqual in tests ([#140](https://github.com/googleapis/nodejs-datastore/pull/140)) +- chore(deps): lock file maintenance ([#138](https://github.com/googleapis/nodejs-datastore/pull/138)) +- chore(build): use `npm ci` instead of `npm install` ([#134](https://github.com/googleapis/nodejs-datastore/pull/134)) +- chore(deps): lock file maintenance ([#133](https://github.com/googleapis/nodejs-datastore/pull/133)) +- chore(deps): lock file maintenance ([#132](https://github.com/googleapis/nodejs-datastore/pull/132)) +- chore(deps): lock file maintenance ([#130](https://github.com/googleapis/nodejs-datastore/pull/130)) +- chore(deps): lock file maintenance ([#128](https://github.com/googleapis/nodejs-datastore/pull/128)) +- chore(deps): lock file maintenance ([#127](https://github.com/googleapis/nodejs-datastore/pull/127)) +- chore(deps): lock file maintenance ([#126](https://github.com/googleapis/nodejs-datastore/pull/126)) +- chore(deps): lock file maintenance ([#125](https://github.com/googleapis/nodejs-datastore/pull/125)) +- chore(deps): lock file maintenance ([#124](https://github.com/googleapis/nodejs-datastore/pull/124)) +- fix(deps): update dependency yargs to v12 ([#122](https://github.com/googleapis/nodejs-datastore/pull/122)) +- fix(deps): update dependency sinon to v6 ([#120](https://github.com/googleapis/nodejs-datastore/pull/120)) +- Configure Renovate ([#113](https://github.com/googleapis/nodejs-datastore/pull/113)) +- Update google-gax dependency ([#119](https://github.com/googleapis/nodejs-datastore/pull/119)) +- refactor: drop repo-tool as an exec wrapper ([#118](https://github.com/googleapis/nodejs-datastore/pull/118)) +- chore: update sample lockfiles ([#117](https://github.com/googleapis/nodejs-datastore/pull/117)) +- fix: update linking for samples ([#115](https://github.com/googleapis/nodejs-datastore/pull/115)) +- chore(package): update eslint to version 5.0.0 ([#114](https://github.com/googleapis/nodejs-datastore/pull/114)) +- chore(package): Update sinon to the latest version 🚀 ([#104](https://github.com/googleapis/nodejs-datastore/pull/104)) diff --git a/handwritten/nodejs-datastore/CODE_OF_CONDUCT.md b/handwritten/nodejs-datastore/CODE_OF_CONDUCT.md new file mode 100644 index 00000000000..2add2547a81 --- /dev/null +++ b/handwritten/nodejs-datastore/CODE_OF_CONDUCT.md @@ -0,0 +1,94 @@ + +# Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/handwritten/nodejs-datastore/CONTRIBUTING.md b/handwritten/nodejs-datastore/CONTRIBUTING.md new file mode 100644 index 00000000000..27ec36b41f9 --- /dev/null +++ b/handwritten/nodejs-datastore/CONTRIBUTING.md @@ -0,0 +1,75 @@ +# How to become a contributor and submit your own code + +**Table of contents** + +* [Contributor License Agreements](#contributor-license-agreements) +* [Contributing a patch](#contributing-a-patch) +* [Running the tests](#running-the-tests) +* [Releasing the library](#releasing-the-library) + +## Contributor License Agreements + +We'd love to accept your sample apps and patches! Before we can take them, we +have to jump a couple of legal hurdles. + +Please fill out either the individual or corporate Contributor License Agreement +(CLA). + + * If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). + * If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). + +Follow either of the two links above to access the appropriate CLA and +instructions for how to sign and return it. Once we receive it, we'll be able to +accept your pull requests. + +## Contributing A Patch + +1. Submit an issue describing your proposed change to the repo in question. +1. The repo owner will respond to your issue promptly. +1. If your proposed change is accepted, and you haven't already done so, sign a + Contributor License Agreement (see details above). +1. Fork the desired repo, develop and test your code changes. +1. Ensure that your code adheres to the existing style in the code to which + you are contributing. +1. Ensure that your code has an appropriate set of tests which all pass. +1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. +1. Submit a pull request. + +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable the Google Cloud Datastore API][enable_api]. +1. [Set up authentication with a service account][auth] so you can access the + API from your local workstation. + + +## Running the tests + +1. [Prepare your environment for Node.js setup][setup]. + +1. Install dependencies: + + npm install + +1. Run the tests: + + # Run unit tests. + npm test + + # Run sample integration tests. + npm run samples-test + + # Run all system tests. + npm run system-test + +1. Lint (and maybe fix) any changes: + + npm run fix + +[setup]: https://cloud.google.com/nodejs/docs/setup +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=datastore.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/getting-started \ No newline at end of file diff --git a/handwritten/nodejs-datastore/LICENSE b/handwritten/nodejs-datastore/LICENSE new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/handwritten/nodejs-datastore/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.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. diff --git a/handwritten/nodejs-datastore/README.md b/handwritten/nodejs-datastore/README.md new file mode 100644 index 00000000000..675530926d6 --- /dev/null +++ b/handwritten/nodejs-datastore/README.md @@ -0,0 +1,191 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." +Google Cloud Platform logo + +# [Google Cloud Datastore: Node.js Client](https://github.com/googleapis/nodejs-datastore) + +[![release level](https://img.shields.io/badge/release%20level-stable-brightgreen.svg?style=flat)](https://cloud.google.com/terms/launch-stages) +[![npm version](https://img.shields.io/npm/v/@google-cloud/datastore.svg)](https://www.npmjs.org/package/@google-cloud/datastore) + + + + +Cloud Datastore Client Library for Node.js + + +A comprehensive list of changes in each version may be found in +[the CHANGELOG](https://github.com/googleapis/nodejs-datastore/blob/main/CHANGELOG.md). + +* [Google Cloud Datastore Node.js Client API Reference][client-docs] +* [Google Cloud Datastore Documentation][product-docs] +* [github.com/googleapis/nodejs-datastore](https://github.com/googleapis/nodejs-datastore) + +Read more about the client libraries for Cloud APIs, including the older +Google APIs Client Libraries, in [Client Libraries Explained][explained]. + +[explained]: https://cloud.google.com/apis/docs/client-libraries-explained + +**Table of contents:** + + +* [Quickstart](#quickstart) + * [Before you begin](#before-you-begin) + * [Installing the client library](#installing-the-client-library) + * [Using the client library](#using-the-client-library) +* [Samples](#samples) +* [Versioning](#versioning) +* [Contributing](#contributing) +* [License](#license) + +## Quickstart + +### Before you begin + +1. [Select or create a Cloud Platform project][projects]. +1. [Enable the Google Cloud Datastore API][enable_api]. +1. [Set up authentication][auth] so you can access the + API from your local workstation. + +### Installing the client library + +```bash +npm install @google-cloud/datastore +``` + + +### Using the client library + +```javascript +// Imports the Google Cloud client library +const {Datastore} = require('@google-cloud/datastore'); + +// Creates a client +const datastore = new Datastore(); + +async function quickstart() { + // The kind for the new entity + const kind = 'Task'; + + // The name/ID for the new entity + const name = 'sampletask1'; + + // The Cloud Datastore key for the new entity + const taskKey = datastore.key([kind, name]); + + // Prepares the new entity + const task = { + key: taskKey, + data: { + description: 'Buy milk', + }, + }; + + // Saves the entity + await datastore.save(task); + console.log(`Saved ${task.key.name}: ${task.data.description}`); +} +quickstart(); + +``` +### Troubleshooting +#### Emulator returning `DEADLINE_EXCEEDED`, `java.lang.OutOfMemoryError` +*Reference Issue: [#95](https://github.com/googleapis/nodejs-datastore/issues/95)* + +When using the emulator, you may experience errors such as "DEADLINE_EXCEEDED" within your application, corresponding to an error in the emulator: "java.lang.OutOfMemoryError". These errors are unique to the emulator environment and will not persist in production. + +A workaround is available, provided by [@ohmpatel1997](https://github.com/ohmpatel1997) [here](https://github.com/googleapis/nodejs-datastore/issues/95#issuecomment-554387312). + + +## Samples + +Samples are in the [`samples/`](https://github.com/googleapis/nodejs-datastore/tree/main/samples) directory. Each sample's `README.md` has instructions for running its sample. + +| Sample | Source Code | Try it | +| --------------------------- | --------------------------------- | ------ | +| Concepts | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/concepts.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/concepts.js,samples/README.md) | +| Error | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/error.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/error.js,samples/README.md) | +| Export | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/export.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/export.js,samples/README.md) | +| Import | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/import.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/import.js,samples/README.md) | +| Indexes.get | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/indexes.get.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/indexes.get.js,samples/README.md) | +| Indexes.list | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/indexes.list.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/indexes.list.js,samples/README.md) | +| Create a union between two filters | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryFilterOr.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryFilterOr.js,samples/README.md) | +| Run query explain (regular query) | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplain.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplain.js,samples/README.md) | +| Run query explain (aggregate query) | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplainAggregation.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplainAggregation.js,samples/README.md) | +| Run query explain analyze (regular query) | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplainAnalyze.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplainAnalyze.js,samples/README.md) | +| Run query explain analyze (aggregate query) | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplainAnalyzeAggregation.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplainAnalyzeAggregation.js,samples/README.md) | +| Quickstart | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | +| Add Task | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.add.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.add.js,samples/README.md) | +| Delete Task | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.delete.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.delete.js,samples/README.md) | +| Legacy Samples | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.js,samples/README.md) | +| List Tasks | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.list.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.list.js,samples/README.md) | +| Update Task | [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.markdone.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.markdone.js,samples/README.md) | + + + +The [Google Cloud Datastore Node.js Client API Reference][client-docs] documentation +also contains samples. + +## Supported Node.js Versions + +Our client libraries follow the [Node.js release schedule](https://github.com/nodejs/release#release-schedule). +Libraries are compatible with all current _active_ and _maintenance_ versions of +Node.js. +If you are using an end-of-life version of Node.js, we recommend that you update +as soon as possible to an actively supported LTS version. + +Google's client libraries support legacy versions of Node.js runtimes on a +best-efforts basis with the following warnings: + +* Legacy versions are not tested in continuous integration. +* Some security patches and features cannot be backported. +* Dependencies cannot be kept up-to-date. + +Client libraries targeting some end-of-life versions of Node.js are available, and +can be installed through npm [dist-tags](https://docs.npmjs.com/cli/dist-tag). +The dist-tags follow the naming convention `legacy-(version)`. +For example, `npm install @google-cloud/datastore@legacy-8` installs client libraries +for versions compatible with Node.js 8. + +## Versioning + +This library follows [Semantic Versioning](http://semver.org/). + + + +This library is considered to be **stable**. The code surface will not change in backwards-incompatible ways +unless absolutely necessary (e.g. because of critical security issues) or with +an extensive deprecation period. Issues and requests against **stable** libraries +are addressed with the highest priority. + + + + + + +More Information: [Google Cloud Platform Launch Stages][launch_stages] + +[launch_stages]: https://cloud.google.com/terms/launch-stages + +## Contributing + +Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-datastore/blob/main/CONTRIBUTING.md). + +Please note that this `README.md`, the `samples/README.md`, +and a variety of configuration files in this repository (including `.nycrc` and `tsconfig.json`) +are generated from a central template. To edit one of these files, make an edit +to its templates in +[directory](https://github.com/googleapis/synthtool). + +## License + +Apache Version 2.0 + +See [LICENSE](https://github.com/googleapis/nodejs-datastore/blob/main/LICENSE) + +[client-docs]: https://cloud.google.com/nodejs/docs/reference/datastore/latest +[product-docs]: https://cloud.google.com/datastore/docs +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png +[projects]: https://console.cloud.google.com/project +[billing]: https://support.google.com/cloud/answer/6293499#enable-billing +[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=datastore.googleapis.com +[auth]: https://cloud.google.com/docs/authentication/external/set-up-adc-local diff --git a/handwritten/nodejs-datastore/linkinator.config.json b/handwritten/nodejs-datastore/linkinator.config.json new file mode 100644 index 00000000000..befd23c8633 --- /dev/null +++ b/handwritten/nodejs-datastore/linkinator.config.json @@ -0,0 +1,16 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io", + "https://console.cloud.google.com/cloudshell", + "https://support.google.com" + ], + "silent": true, + "concurrency": 5, + "retry": true, + "retryErrors": true, + "retryErrorsCount": 5, + "retryErrorsJitter": 3000 +} diff --git a/handwritten/nodejs-datastore/mock-server/README.md b/handwritten/nodejs-datastore/mock-server/README.md new file mode 100644 index 00000000000..53a848410ee --- /dev/null +++ b/handwritten/nodejs-datastore/mock-server/README.md @@ -0,0 +1,15 @@ +The mock server code in this folder is used for observing requests that will +be sent to the server. When the server sends back a vague error it is often +because the request it receives is incorrect so it is crucial to have a tool to +view the request in order to know what client library code needs to change. + +The steps to follow for using the mock server is: +1. Take a look at `test/try-server.ts` to see how the mock server is used. +2. In the system test you want to debug, change `it` to `it.only` to isolate that test. +3. In this test, surround the code with `startServer(async () => {` +4. Ensure `apiEndpoint: 'localhost:50051'` is passed into the datastore client that is used for this test. +5. If the system test hits an endpoint other than `runQuery` then in `datastore-server.ts`, change `.addService(service, {runQuery: grpcEndpoint})` to `.addService(service, {<>: grpcEndpoint})` +6. Set a breakpoint on the line that says `SET A BREAKPOINT HERE` in `datastore-server.ts` +7. Debug with system tests (Enter `npm run system-test -- --inspect` in terminal) + + diff --git a/handwritten/nodejs-datastore/mock-server/datastore-server.ts b/handwritten/nodejs-datastore/mock-server/datastore-server.ts new file mode 100644 index 00000000000..c2e1ee5f2d6 --- /dev/null +++ b/handwritten/nodejs-datastore/mock-server/datastore-server.ts @@ -0,0 +1,67 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +const {dirname, resolve} = require('node:path'); + +const PROTO_PATH = __dirname + '/../protos/google/datastore/v1/datastore.proto'; +const DATASTORE_PROTOS = __dirname + '/../protos'; +const GAX_PROTOS_DIR = resolve( + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + // eslint-disable-next-line n/no-extraneous-require + dirname(require.resolve('google-gax')), + '../protos', +); + +const grpc = require('@grpc/grpc-js'); +const protoLoader = require('@grpc/proto-loader'); + +const packageDefinition = protoLoader.loadSync(PROTO_PATH, { + keepCase: true, + longs: String, + enums: String, + defaults: true, + oneofs: true, + includeDirs: [DATASTORE_PROTOS, GAX_PROTOS_DIR], +}); +const descriptor = grpc.loadPackageDefinition(packageDefinition); + +/** + * Implements the runQuery RPC method. + */ +function grpcEndpoint( + call: {}, + callback: (arg1: string | null, arg2: {}) => {}, +) { + // SET A BREAKPOINT HERE AND EXPLORE `call` TO SEE THE REQUEST. + callback(null, {message: 'Hello'}); +} + +/** + * Starts an RPC server that receives requests for datastore + */ +export function startServer(cb: () => void) { + const server = new grpc.Server(); + const service = descriptor.google.datastore.v1.Datastore.service; + // On the next line, change runQuery to the grpc method you want to investigate + server.addService(service, {runQuery: grpcEndpoint}); + server.bindAsync( + '0.0.0.0:50051', + grpc.ServerCredentials.createInsecure(), + () => { + console.log('server started'); + cb(); + }, + ); +} diff --git a/handwritten/nodejs-datastore/mock-server/package.json b/handwritten/nodejs-datastore/mock-server/package.json new file mode 100644 index 00000000000..73153dee4d6 --- /dev/null +++ b/handwritten/nodejs-datastore/mock-server/package.json @@ -0,0 +1,12 @@ +{ + "name": "grpc-examples", + "version": "0.1.0", + "dependencies": { + "@grpc/proto-loader": "^0.5.0", + "async": "^1.5.2", + "google-protobuf": "^3.0.0", + "@grpc/grpc-js": "^1.1.0", + "lodash": "^4.6.1", + "minimist": "^1.2.0" + } +} diff --git a/handwritten/nodejs-datastore/owlbot.py b/handwritten/nodejs-datastore/owlbot.py new file mode 100644 index 00000000000..a6af6e71f31 --- /dev/null +++ b/handwritten/nodejs-datastore/owlbot.py @@ -0,0 +1,60 @@ +# 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. + +import synthtool as s +import synthtool.gcp as gcp +import synthtool.languages.node_mono_repo as node +import logging +from pathlib import Path +from synthtool import _tracked_paths +from synthtool import shell +import shutil + +logging.basicConfig(level=logging.DEBUG) + +staging = Path("owl-bot-staging") + +if staging.is_dir(): + logging.info(f"Copying files from staging directory ${staging}.") + + # Copy the datastore library. + for version in ['v1']: + library = staging / version + _tracked_paths.add(library) + s.copy([library],excludes=[ + 'package.json', 'README.md', 'src/index.ts', 'src/v1/index.ts']) + + # Copy the admin library. + for version in ['v1']: + library = staging / 'admin' / version + _tracked_paths.add(library) + s.copy([library],excludes=[ + 'package.json', 'README.md', 'src/index.ts', 'src/v1/index.ts', 'tsconfig.json', 'tslint.json', + 'system-test/fixtures/sample/src/index.ts', 'system-test/fixtures/sample/src/index.js', + '.jsdoc.js', 'webpack.config.js']) + + # Patch the code. + system_test_files = ['system-test/fixtures/sample/src/index.ts', 'system-test/fixtures/sample/src/index.js'] + for file in system_test_files: + s.replace(file, 'DatastoreClient', 'Datastore') + s.replace(file, 'client.close', '// client.close'); # does not work with the manual layer + + # The staging directory should never be merged into the main branch. + shutil.rmtree(staging) + +common_templates = gcp.CommonTemplates() +templates = common_templates.node_library(source_location="build/src") +s.copy(templates) + +node.postprocess_gapic_library_hermetic() diff --git a/handwritten/nodejs-datastore/package.json b/handwritten/nodejs-datastore/package.json new file mode 100644 index 00000000000..982900ba920 --- /dev/null +++ b/handwritten/nodejs-datastore/package.json @@ -0,0 +1,93 @@ +{ + "name": "@google-cloud/datastore", + "version": "10.0.1", + "description": "Cloud Datastore Client Library for Node.js", + "keywords": [ + "google apis client", + "google api client", + "google apis", + "google api", + "google", + "google cloud platform", + "google cloud", + "cloud", + "google datastore", + "datastore" + ], + "repository": { + "type": "git", + "directory": "handwritten/nodejs-datastore", + "url": "https://github.com/googleapis/google-cloud-node.git" + }, + "license": "Apache-2.0", + "author": "Google LLC.", + "main": "build/src/index.js", + "files": [ + "build/protos", + "build/src" + ], + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r proto* build/ && cp -r system-test/data build/system-test", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "predocs-test": "npm run docs", + "docs-test": "linkinator docs", + "fix": "gts fix", + "prelint": "cd samples; npm link ../; npm install", + "lint": "gts check", + "prepare": "npm run compile-protos && npm run compile", + "samples-test": "cd samples/ && npm link ../ && npm install && npm test && cd ../", + "presystem-test": "npm run compile", + "system-test": "mocha build/system-test --timeout 600000", + "pretest": "npm run compile", + "test": "c8 mocha build/test", + "precompile": "gts clean" + }, + "dependencies": { + "@google-cloud/promisify": "^5.0.0", + "arrify": "^2.0.0", + "async-mutex": "^0.5.0", + "concat-stream": "^2.0.0", + "extend": "^3.0.2", + "google-gax": "^5.0.2-rc.1", + "is": "^3.3.0", + "long": "^4.0.0", + "protobufjs": "7.4.0", + "split-array-stream": "^2.0.0", + "stream-events": "^1.0.5" + }, + "devDependencies": { + "@google-cloud/storage": "^7.16.0", + "@types/extend": "^3.0.4", + "@types/is": "^0.0.25", + "@types/js-yaml": "^4.0.9", + "@types/mocha": "^10.0.10", + "@types/node": "^22.15.3", + "@types/long": "^4.0.0", + "@types/proxyquire": "^1.3.31", + "@types/sinon": "^17.0.4", + "async": "^3.2.6", + "c8": "^10.1.3", + "gapic-tools": "^1.0.2", + "gts": "^6.0.2", + "js-yaml": "^4.1.0", + "jsdoc": "^4.0.4", + "jsdoc-fresh": "^3.0.0", + "jsdoc-region-tag": "^3.0.0", + "linkinator": "^6.1.2", + "mocha": "^11.1.0", + "null-loader": "^4.0.1", + "p-queue": "^8.1.0", + "pack-n-play": "^3.0.1", + "proxyquire": "^2.1.3", + "sinon": "^20.0.0", + "ts-loader": "^9.5.2", + "typescript": "^5.8.3", + "webpack-cli": "^6.0.1" + }, + "engines": { + "node": ">=18" + }, + "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/handwritten/nodejs-datastore" +} diff --git a/handwritten/nodejs-datastore/protos/app_engine_key.proto b/handwritten/nodejs-datastore/protos/app_engine_key.proto new file mode 100644 index 00000000000..0f62d0124c0 --- /dev/null +++ b/handwritten/nodejs-datastore/protos/app_engine_key.proto @@ -0,0 +1,16 @@ +syntax = "proto2"; + +message Reference { + required string app = 13; + optional string namespace = 20; + required Path path = 14; + optional string database_id = 23; +} + +message Path { + repeated group Element = 1 { + required string type = 2; + optional int64 id = 3; + optional string name = 4; + } +} diff --git a/handwritten/nodejs-datastore/protos/google/cloud/common_resources.proto b/handwritten/nodejs-datastore/protos/google/cloud/common_resources.proto new file mode 100644 index 00000000000..56c9f800d5e --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/cloud/common_resources.proto @@ -0,0 +1,52 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.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. + +// This file contains stub messages for common resources in GCP. +// It is not intended to be directly generated, and is instead used by +// other tooling to be able to match common resource patterns. +syntax = "proto3"; + +package google.cloud; + +import "google/api/resource.proto"; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Project" + pattern: "projects/{project}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Organization" + pattern: "organizations/{organization}" +}; + + +option (google.api.resource_definition) = { + type: "cloudresourcemanager.googleapis.com/Folder" + pattern: "folders/{folder}" +}; + + +option (google.api.resource_definition) = { + type: "cloudbilling.googleapis.com/BillingAccount" + pattern: "billingAccounts/{billing_account}" +}; + +option (google.api.resource_definition) = { + type: "locations.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; + diff --git a/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/datastore_admin.proto b/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/datastore_admin.proto new file mode 100644 index 00000000000..50c4d0cc87e --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/datastore_admin.proto @@ -0,0 +1,506 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.admin.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/datastore/admin/v1/index.proto"; +import "google/datastore/admin/v1/migration.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "DatastoreAdminProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// Google Cloud Datastore Admin API +// +// The Datastore Admin API provides several admin services for Cloud Datastore. +// +// Concepts: Project, namespace, kind, and entity as defined in the Google Cloud +// Datastore API. +// +// Operation: An Operation represents work being performed in the background. +// +// EntityFilter: Allows specifying a subset of entities in a project. This is +// specified as a combination of kinds and namespaces (either or both of which +// may be all). +// +// Export/Import Service: +// +// - The Export/Import service provides the ability to copy all or a subset of +// entities to/from Google Cloud Storage. +// - Exported data may be imported into Cloud Datastore for any Google Cloud +// Platform project. It is not restricted to the export source project. It is +// possible to export from one project and then import into another. +// - Exported data can also be loaded into Google BigQuery for analysis. +// - Exports and imports are performed asynchronously. An Operation resource is +// created for each export/import. The state (including any errors encountered) +// of the export/import may be queried via the Operation resource. +// +// Index Service: +// +// - The index service manages Cloud Datastore composite indexes. +// - Index creation and deletion are 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. +// +// Operation Service: +// +// - 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 not yet done may be cancelled. The request to cancel +// is asynchronous and the operation may continue to run for some time after the +// request to cancel is made. +// - An operation that is done may be deleted so that it is no longer listed as +// part of the Operation collection. +// - ListOperations returns all pending operations, but not completed +// operations. +// - Operations are created by service DatastoreAdmin, but are accessed via +// service google.longrunning.Operations. +service DatastoreAdmin { + option (google.api.default_host) = "datastore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Exports a copy of all or a subset of entities from Google Cloud Datastore + // to another storage system, such as Google Cloud Storage. Recent updates to + // entities 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. + rpc ExportEntities(ExportEntitiesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:export" + body: "*" + }; + option (google.api.method_signature) = + "project_id,labels,entity_filter,output_url_prefix"; + option (google.longrunning.operation_info) = { + response_type: "ExportEntitiesResponse" + metadata_type: "ExportEntitiesMetadata" + }; + } + + // Imports entities into Google Cloud Datastore. Existing entities with the + // same key 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 ImportEntities operation is cancelled, it is possible + // that a subset of the data has already been imported to Cloud Datastore. + rpc ImportEntities(ImportEntitiesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:import" + body: "*" + }; + option (google.api.method_signature) = + "project_id,labels,input_url,entity_filter"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "ImportEntitiesMetadata" + }; + } + + // Creates the specified index. + // A newly created index's initial state is `CREATING`. On completion of the + // returned [google.longrunning.Operation][google.longrunning.Operation], the + // state will be `READY`. If the index already exists, the call will return an + // `ALREADY_EXISTS` status. + // + // During index creation, the process could result in an error, in which + // case the index will move to the `ERROR` state. The process can be recovered + // by fixing the data that caused the error, removing the index with + // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then + // re-creating the index with [create] + // [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + // + // Indexes with a single property cannot be created. + rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}/indexes" + body: "index" + }; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Deletes an existing index. + // An index can only be deleted if it is in a `READY` or `ERROR` state. On + // successful execution of the request, the index will be in a `DELETING` + // [state][google.datastore.admin.v1.Index.State]. And on completion of the + // returned [google.longrunning.Operation][google.longrunning.Operation], the + // index will be removed. + // + // During index deletion, the process could result in an error, in which + // case the index will move to the `ERROR` state. The process can be recovered + // by fixing the data that caused the error, followed by calling + // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. + rpc DeleteIndex(DeleteIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/projects/{project_id}/indexes/{index_id}" + }; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Gets an index. + rpc GetIndex(GetIndexRequest) returns (Index) { + option (google.api.http) = { + get: "/v1/projects/{project_id}/indexes/{index_id}" + }; + } + + // Lists the indexes that match the specified filters. Datastore uses an + // eventually consistent query to fetch the list of indexes and may + // occasionally return stale results. + rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { + option (google.api.http) = { + get: "/v1/projects/{project_id}/indexes" + }; + } +} + +// Metadata common to all Datastore Admin operations. +message CommonMetadata { + // The various possible states for an ongoing Operation. + enum State { + // Unspecified. + 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; + } + + // The time that work began on the operation. + google.protobuf.Timestamp start_time = 1; + + // The time the operation ended, either successfully or otherwise. + google.protobuf.Timestamp end_time = 2; + + // The type of the operation. Can be used as a filter in + // ListOperationsRequest. + OperationType operation_type = 3; + + // The client-assigned labels which were provided when the operation was + // created. May also include additional labels. + map labels = 4; + + // The current state of the Operation. + State state = 5; +} + +// Measures the progress of a particular metric. +message Progress { + // The amount of work that has been completed. Note that this may be greater + // than work_estimated. + int64 work_completed = 1; + + // An estimate of how much work needs to be performed. May be zero if the + // work estimate is unavailable. + int64 work_estimated = 2; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. +message ExportEntitiesRequest { + // Required. Project ID against which to make the request. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Client-assigned labels. + map labels = 2; + + // Description of what data from the project is included in the export. + EntityFilter entity_filter = 3; + + // Required. Location for the export metadata and data files. + // + // The full resource URL of the external storage location. Currently, only + // Google Cloud Storage is supported. So output_url_prefix should be of the + // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the + // name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud + // Storage namespace path (this is not a Cloud Datastore namespace). For more + // information about Cloud Storage namespace paths, see + // [Object name + // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + // + // The resulting files will be nested deeper than the specified URL prefix. + // The final output URL will be provided in the + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] + // field. That value should be used for subsequent ImportEntities operations. + // + // By nesting the data files deeper, the same Cloud Storage bucket can be used + // in multiple ExportEntities operations without conflict. + string output_url_prefix = 4 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1.DatastoreAdmin.ImportEntities]. +message ImportEntitiesRequest { + // Required. Project ID against which to make the request. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Client-assigned labels. + map labels = 2; + + // Required. The full resource URL of the external storage location. + // Currently, only Google Cloud Storage is supported. So input_url should be + // of the form: + // `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where + // `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is + // an optional Cloud Storage namespace path (this is not a Cloud Datastore + // namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written + // by the ExportEntities operation. For more information about Cloud Storage + // namespace paths, see + // [Object name + // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + // + // For more information, see + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. + string input_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optionally specify which kinds/namespaces are to be imported. If provided, + // the list must be a subset of the EntityFilter used in creating the export, + // otherwise a FAILED_PRECONDITION error will be returned. If no filter is + // specified then all entities from the export are imported. + EntityFilter entity_filter = 4; +} + +// The response for +// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. +message ExportEntitiesResponse { + // Location of the output metadata file. This can be used to begin an import + // into Cloud Datastore (this project or another project). See + // [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url]. + // Only present if the operation completed successfully. + string output_url = 1; +} + +// Metadata for ExportEntities operations. +message ExportEntitiesMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // An estimate of the number of bytes processed. + Progress progress_bytes = 3; + + // Description of which entities are being exported. + EntityFilter entity_filter = 4; + + // Location for the export metadata and data files. This will be the same + // value as the + // [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix] + // field. The final output location is provided in + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. + string output_url_prefix = 5; +} + +// Metadata for ImportEntities operations. +message ImportEntitiesMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // An estimate of the number of bytes processed. + Progress progress_bytes = 3; + + // Description of which entities are being imported. + EntityFilter entity_filter = 4; + + // The location of the import metadata file. This will be the same value as + // the + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] + // field. + string input_url = 5; +} + +// Identifies a subset of entities in a project. This is specified as +// combinations of kinds and namespaces (either or both of which may be all, as +// described in the following examples). +// Example usage: +// +// Entire project: +// kinds=[], namespace_ids=[] +// +// Kinds Foo and Bar in all namespaces: +// kinds=['Foo', 'Bar'], namespace_ids=[] +// +// Kinds Foo and Bar only in the default namespace: +// kinds=['Foo', 'Bar'], namespace_ids=[''] +// +// Kinds Foo and Bar in both the default and Baz namespaces: +// kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz'] +// +// The entire Baz namespace: +// kinds=[], namespace_ids=['Baz'] +message EntityFilter { + // If empty, then this represents all kinds. + repeated string kinds = 1; + + // An empty list represents all namespaces. This is the preferred + // usage for projects that don't use namespaces. + // + // An empty string element represents the default namespace. This should be + // used if the project has data in non-default namespaces, but doesn't want to + // include them. + // Each namespace in this list must be unique. + repeated string namespace_ids = 2; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.CreateIndex][google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. +message CreateIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The index to create. The name and state fields are output only and will be + // ignored. Single property indexes cannot be created or deleted. + Index index = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.DeleteIndex][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]. +message DeleteIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The resource ID of the index to delete. + string index_id = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.GetIndex][google.datastore.admin.v1.DatastoreAdmin.GetIndex]. +message GetIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The resource ID of the index to get. + string index_id = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. +message ListIndexesRequest { + // Project ID against which to make the request. + string project_id = 1; + + string filter = 3; + + // The maximum number of items to return. If zero, then all results will be + // returned. + int32 page_size = 4; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 5; +} + +// The response for +// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. +message ListIndexesResponse { + // The indexes. + repeated Index indexes = 1; + + // The standard List next-page token. + string next_page_token = 2; +} + +// Metadata for Index operations. +message IndexOperationMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // The index resource ID that this operation is acting on. + string index_id = 3; +} + +// Metadata for Datastore to Firestore migration operations. +// +// The DatastoreFirestoreMigration operation is not started by the end-user via +// an explicit "creation" method. This is an intentional deviation from the LRO +// design pattern. +// +// This singleton resource can be accessed at: +// "projects/{project_id}/operations/datastore-firestore-migration" +message DatastoreFirestoreMigrationMetadata { + // The current state of migration from Cloud Datastore to Cloud Firestore in + // Datastore mode. + MigrationState migration_state = 1; + + // The current step of migration from Cloud Datastore to Cloud Firestore in + // Datastore mode. + MigrationStep migration_step = 2; +} + +// Operation types. +enum OperationType { + // Unspecified. + OPERATION_TYPE_UNSPECIFIED = 0; + + // ExportEntities. + EXPORT_ENTITIES = 1; + + // ImportEntities. + IMPORT_ENTITIES = 2; + + // CreateIndex. + CREATE_INDEX = 3; + + // DeleteIndex. + DELETE_INDEX = 4; +} diff --git a/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/index.proto b/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/index.proto new file mode 100644 index 00000000000..c907660568c --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/index.proto @@ -0,0 +1,122 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.admin.v1; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "IndexProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// Datastore composite index definition. +message Index { + // For an ordered index, specifies whether each of the entity's ancestors + // will be included. + enum AncestorMode { + // The ancestor mode is unspecified. + ANCESTOR_MODE_UNSPECIFIED = 0; + + // Do not include the entity's ancestors in the index. + NONE = 1; + + // Include all the entity's ancestors in the index. + ALL_ANCESTORS = 2; + } + + // The direction determines how a property is indexed. + enum Direction { + // The direction is unspecified. + DIRECTION_UNSPECIFIED = 0; + + // The property's values are indexed so as to support sequencing in + // ascending order and also query by <, >, <=, >=, and =. + ASCENDING = 1; + + // The property's values are indexed so as to support sequencing in + // descending order and also query by <, >, <=, >=, and =. + DESCENDING = 2; + } + + // A property of an index. + message IndexedProperty { + // Required. The property name to index. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The indexed property's direction. Must not be + // DIRECTION_UNSPECIFIED. + Direction direction = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // The possible set of states of an index. + enum State { + // The state is unspecified. + STATE_UNSPECIFIED = 0; + + // The index is being created, and cannot be used by queries. + // There is an active long-running operation for the index. + // The index is updated when writing an entity. + // Some index data may exist. + CREATING = 1; + + // The index is ready to be used. + // The index is updated when writing an entity. + // The index is fully populated from all stored entities it applies to. + READY = 2; + + // The index is being deleted, and cannot be used by queries. + // There is an active long-running operation for the index. + // The index is not updated when writing an entity. + // Some index data may exist. + DELETING = 3; + + // The index was being created or deleted, but something went wrong. + // The index cannot by used by queries. + // 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 an entity. + // Some index data may exist. + ERROR = 4; + } + + // Output only. Project ID. + string project_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The resource ID of the index. + string index_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The entity kind to which this index applies. + string kind = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. The index's ancestor mode. Must not be + // ANCESTOR_MODE_UNSPECIFIED. + AncestorMode ancestor = 5 [(google.api.field_behavior) = REQUIRED]; + + // Required. An ordered sequence of property names and their index attributes. + // + // Requires: + // + // * A maximum of 100 properties. + repeated IndexedProperty properties = 6 + [(google.api.field_behavior) = REQUIRED]; + + // Output only. The state of the index. + State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/migration.proto b/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/migration.proto new file mode 100644 index 00000000000..67ac1ab711d --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/admin/v1/migration.proto @@ -0,0 +1,124 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.admin.v1; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "MigrationProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// An event signifying a change in state of a [migration from Cloud Datastore to +// Cloud Firestore in Datastore +// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). +message MigrationStateEvent { + // The new state of the migration. + MigrationState state = 1; +} + +// An event signifying the start of a new step in a [migration from Cloud +// Datastore to Cloud Firestore in Datastore +// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). +message MigrationProgressEvent { + // Concurrency modes for transactions in Cloud Firestore. + enum ConcurrencyMode { + // Unspecified. + CONCURRENCY_MODE_UNSPECIFIED = 0; + + // Pessimistic concurrency. + PESSIMISTIC = 1; + + // Optimistic concurrency. + OPTIMISTIC = 2; + + // Optimistic concurrency with entity groups. + OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + } + + // Details for the `PREPARE` step. + message PrepareStepDetails { + // The concurrency mode this database will use when it reaches the + // `REDIRECT_WRITES` step. + ConcurrencyMode concurrency_mode = 1; + } + + // Details for the `REDIRECT_WRITES` step. + message RedirectWritesStepDetails { + // Ths concurrency mode for this database. + ConcurrencyMode concurrency_mode = 1; + } + + // The step that is starting. + // + // An event with step set to `START` indicates that the migration + // has been reverted back to the initial pre-migration state. + MigrationStep step = 1; + + // Details about this step. + oneof step_details { + // Details for the `PREPARE` step. + PrepareStepDetails prepare_step_details = 2; + + // Details for the `REDIRECT_WRITES` step. + RedirectWritesStepDetails redirect_writes_step_details = 3; + } +} + +// States for a migration. +enum MigrationState { + // Unspecified. + MIGRATION_STATE_UNSPECIFIED = 0; + + // The migration is running. + RUNNING = 1; + + // The migration is paused. + PAUSED = 2; + + // The migration is complete. + COMPLETE = 3; +} + +// Steps in a migration. +enum MigrationStep { + // Unspecified. + MIGRATION_STEP_UNSPECIFIED = 0; + + // Pre-migration: the database is prepared for migration. + PREPARE = 6; + + // Start of migration. + START = 1; + + // Writes are applied synchronously to at least one replica. + APPLY_WRITES_SYNCHRONOUSLY = 7; + + // Data is copied to Cloud Firestore and then verified to match the data in + // Cloud Datastore. + COPY_AND_VERIFY = 2; + + // Eventually-consistent reads are redirected to Cloud Firestore. + REDIRECT_EVENTUALLY_CONSISTENT_READS = 3; + + // Strongly-consistent reads are redirected to Cloud Firestore. + REDIRECT_STRONGLY_CONSISTENT_READS = 4; + + // Writes are redirected to Cloud Firestore. + REDIRECT_WRITES = 5; +} diff --git a/handwritten/nodejs-datastore/protos/google/datastore/v1/aggregation_result.proto b/handwritten/nodejs-datastore/protos/google/datastore/v1/aggregation_result.proto new file mode 100644 index 00000000000..cd51f660c41 --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/v1/aggregation_result.proto @@ -0,0 +1,62 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.v1; + +import "google/datastore/v1/entity.proto"; +import "google/datastore/v1/query.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "AggregationResultProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// The result of a single bucket from a Datastore aggregation query. +// +// The keys of `aggregate_properties` are the same for all results in an +// aggregation query, unlike entity queries which can have different fields +// present for each result. +message AggregationResult { + // The result of the aggregation functions, ex: `COUNT(*) AS total_entities`. + // + // The key is the + // [alias][google.datastore.v1.AggregationQuery.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_properties = 2; +} + +// A batch of aggregation results produced by an aggregation query. +message AggregationResultBatch { + // The aggregation results for this batch. + repeated AggregationResult aggregation_results = 1; + + // The state of the query after the current batch. + // Only COUNT(*) aggregations are supported in the initial launch. Therefore, + // expected result type is limited to `NO_MORE_RESULTS`. + QueryResultBatch.MoreResultsType more_results = 2; + + // Read timestamp this batch was returned from. + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater timestamp. Each batch's read timestamp + // is valid for all preceding batches. + google.protobuf.Timestamp read_time = 3; +} diff --git a/handwritten/nodejs-datastore/protos/google/datastore/v1/datastore.proto b/handwritten/nodejs-datastore/protos/google/datastore/v1/datastore.proto new file mode 100644 index 00000000000..c0a281b1879 --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/v1/datastore.proto @@ -0,0 +1,810 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/routing.proto"; +import "google/datastore/v1/aggregation_result.proto"; +import "google/datastore/v1/entity.proto"; +import "google/datastore/v1/query.proto"; +import "google/datastore/v1/query_profile.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "DatastoreProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// Each RPC normalizes the partition IDs of the keys in its input entities, +// and always returns entities with keys with normalized partition IDs. +// This applies to all keys and entities, including those in values, except keys +// with both an empty path and an empty or unset partition ID. Normalization of +// input keys sets the project ID (if not already set) to the project ID from +// the request. +// +service Datastore { + option (google.api.default_host) = "datastore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Looks up entities by key. + rpc Lookup(LookupRequest) returns (LookupResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:lookup" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,read_options,keys"; + } + + // Queries for entities. + rpc RunQuery(RunQueryRequest) returns (RunQueryResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:runQuery" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + } + + // Runs an aggregation query. + rpc RunAggregationQuery(RunAggregationQueryRequest) + returns (RunAggregationQueryResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:runAggregationQuery" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + } + + // Begins a new transaction. + rpc BeginTransaction(BeginTransactionRequest) + returns (BeginTransactionResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:beginTransaction" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id"; + } + + // Commits a transaction, optionally creating, deleting or modifying some + // entities. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:commit" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = + "project_id,mode,transaction,mutations"; + option (google.api.method_signature) = "project_id,mode,mutations"; + } + + // Rolls back a transaction. + rpc Rollback(RollbackRequest) returns (RollbackResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:rollback" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,transaction"; + } + + // Allocates IDs for the given keys, which is useful for referencing an entity + // before it is inserted. + rpc AllocateIds(AllocateIdsRequest) returns (AllocateIdsResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:allocateIds" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,keys"; + } + + // Prevents the supplied keys' IDs from being auto-allocated by Cloud + // Datastore. + rpc ReserveIds(ReserveIdsRequest) returns (ReserveIdsResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:reserveIds" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,keys"; + } +} + +// The request for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup]. +message LookupRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // The options for this lookup request. + ReadOptions read_options = 1; + + // Required. Keys of entities to look up. + repeated Key keys = 3 [(google.api.field_behavior) = REQUIRED]; + + // The properties to return. Defaults to returning all properties. + // + // If this field is set and an entity has a property not referenced in the + // mask, it will be absent from [LookupResponse.found.entity.properties][]. + // + // The entity's key is always returned. + PropertyMask property_mask = 5; +} + +// The response for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup]. +message LookupResponse { + // Entities found as `ResultType.FULL` entities. The order of results in this + // field is undefined and has no relation to the order of the keys in the + // input. + repeated EntityResult found = 1; + + // Entities not found as `ResultType.KEY_ONLY` entities. The order of results + // in this field is undefined and has no relation to the order of the keys + // in the input. + repeated EntityResult missing = 2; + + // A list of keys that were not looked up due to resource constraints. The + // order of results in this field is undefined and has no relation to the + // order of the keys in the input. + repeated Key deferred = 3; + + // The identifier of the transaction that was started as part of this Lookup + // request. + // + // Set only when + // [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] + // was set in + // [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options]. + bytes transaction = 5; + + // The time at which these entities were read or found missing. + google.protobuf.Timestamp read_time = 7; +} + +// The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. +message RunQueryRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Entities are partitioned into subsets, identified by a partition ID. + // Queries are scoped to a single partition. + // This partition ID is normalized with the standard default context + // partition ID. + PartitionId partition_id = 2; + + // The options for this query. + ReadOptions read_options = 1; + + // The type of query. + oneof query_type { + // The query to run. + Query query = 3; + + // The GQL query to run. This query must be a non-aggregation query. + GqlQuery gql_query = 7; + } + + // The properties to return. + // This field must not be set for a projection query. + // + // See + // [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. + PropertyMask property_mask = 10; + + // Optional. Explain options for the query. If set, additional query + // statistics will be returned. If not, only query results will be returned. + ExplainOptions explain_options = 12 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. +message RunQueryResponse { + // A batch of query results (always present). + QueryResultBatch batch = 1; + + // The parsed form of the `GqlQuery` from the request, if it was set. + Query query = 2; + + // The identifier of the transaction that was started as part of this + // RunQuery request. + // + // Set only when + // [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] + // was set in + // [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options]. + bytes transaction = 5; + + // Query explain metrics. This is only present when the + // [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options] + // is provided, and it is sent only once with the last response in the stream. + ExplainMetrics explain_metrics = 9; +} + +// The request for +// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. +message RunAggregationQueryRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Entities are partitioned into subsets, identified by a partition ID. + // Queries are scoped to a single partition. + // This partition ID is normalized with the standard default context + // partition ID. + PartitionId partition_id = 2; + + // The options for this query. + ReadOptions read_options = 1; + + // The type of query. + oneof query_type { + // The query to run. + AggregationQuery aggregation_query = 3; + + // The GQL query to run. This query must be an aggregation query. + GqlQuery gql_query = 7; + } + + // Optional. Explain options for the query. If set, additional query + // statistics will be returned. If not, only query results will be returned. + ExplainOptions explain_options = 11 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. +message RunAggregationQueryResponse { + // A batch of aggregation results. Always present. + AggregationResultBatch batch = 1; + + // The parsed form of the `GqlQuery` from the request, if it was set. + AggregationQuery query = 2; + + // The identifier of the transaction that was started as part of this + // RunAggregationQuery request. + // + // Set only when + // [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] + // was set in + // [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options]. + bytes transaction = 5; + + // Query explain metrics. This is only present when the + // [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options] + // is provided, and it is sent only once with the last response in the stream. + ExplainMetrics explain_metrics = 9; +} + +// The request for +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. +message BeginTransactionRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Options for a new transaction. + TransactionOptions transaction_options = 10; +} + +// The response for +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. +message BeginTransactionResponse { + // The transaction identifier (always present). + bytes transaction = 1; +} + +// The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. +message RollbackRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Required. The transaction identifier, returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for +// [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. (an empty +// message). +message RollbackResponse {} + +// The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit]. +message CommitRequest { + // The modes available for commits. + enum Mode { + // Unspecified. This value must not be used. + MODE_UNSPECIFIED = 0; + + // Transactional: The mutations are either all applied, or none are applied. + // Learn about transactions + // [here](https://cloud.google.com/datastore/docs/concepts/transactions). + TRANSACTIONAL = 1; + + // Non-transactional: The mutations may not apply as all or none. + NON_TRANSACTIONAL = 2; + } + + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // The type of commit to perform. Defaults to `TRANSACTIONAL`. + Mode mode = 5; + + // Must be set when mode is `TRANSACTIONAL`. + oneof transaction_selector { + // The identifier of the transaction associated with the commit. A + // transaction identifier is returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 1; + + // Options for beginning a new transaction for this request. + // The transaction is committed when the request completes. If specified, + // [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be + // [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite]. + TransactionOptions single_use_transaction = 10; + } + + // The mutations to perform. + // + // When mode is `TRANSACTIONAL`, mutations affecting a single entity are + // applied in order. The following sequences of mutations affecting a single + // entity are not permitted in a single `Commit` request: + // + // - `insert` followed by `insert` + // - `update` followed by `insert` + // - `upsert` followed by `insert` + // - `delete` followed by `update` + // + // When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single + // entity. + repeated Mutation mutations = 6; +} + +// The response for [Datastore.Commit][google.datastore.v1.Datastore.Commit]. +message CommitResponse { + // The result of performing the mutations. + // The i-th mutation result corresponds to the i-th mutation in the request. + repeated MutationResult mutation_results = 3; + + // The number of index entries updated during the commit, or zero if none were + // updated. + int32 index_updates = 4; + + // The transaction commit timestamp. Not set for non-transactional commits. + google.protobuf.Timestamp commit_time = 8; +} + +// The request for +// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. +message AllocateIdsRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Required. A list of keys with incomplete key paths for which to allocate + // IDs. No key may be reserved/read-only. + repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for +// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. +message AllocateIdsResponse { + // The keys specified in the request (in the same order), each with + // its key path completed with a newly allocated ID. + repeated Key keys = 1; +} + +// The request for +// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. +message ReserveIdsRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Required. A list of keys with complete key paths whose numeric IDs should + // not be auto-allocated. + repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for +// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. +message ReserveIdsResponse {} + +// A mutation to apply to an entity. +message Mutation { + // The possible ways to resolve a conflict detected in a mutation. + enum ConflictResolutionStrategy { + // Unspecified. Defaults to `SERVER_VALUE`. + STRATEGY_UNSPECIFIED = 0; + + // The server entity is kept. + SERVER_VALUE = 1; + + // The whole commit request fails. + FAIL = 3; + } + + // The mutation operation. + // + // For `insert`, `update`, and `upsert`: + // - The entity's key must not be reserved/read-only. + // - No property in the entity may have a reserved name, + // not even a property in an entity in a value. + // - No value in the entity may have meaning 18, + // not even a value in an entity in another value. + oneof operation { + // The entity to insert. The entity must not already exist. + // The entity key's final path element may be incomplete. + Entity insert = 4; + + // The entity to update. The entity must already exist. + // Must have a complete key path. + Entity update = 5; + + // The entity to upsert. The entity may or may not already exist. + // The entity key's final path element may be incomplete. + Entity upsert = 6; + + // The key of the entity to delete. The entity may or may not already exist. + // Must have a complete key path and must not be reserved/read-only. + Key delete = 7; + } + + // When set, the server will detect whether or not this mutation conflicts + // with the current version of the entity on the server. Conflicting mutations + // are not applied, and are marked as such in MutationResult. + oneof conflict_detection_strategy { + // The version of the entity that this mutation is being applied + // to. If this does not match the current version on the server, the + // mutation conflicts. + int64 base_version = 8; + + // The update time of the entity that this mutation is being applied + // to. If this does not match the current update time on the server, the + // mutation conflicts. + google.protobuf.Timestamp update_time = 11; + } + + // The strategy to use when a conflict is detected. Defaults to + // `SERVER_VALUE`. + // If this is set, then `conflict_detection_strategy` must also be set. + ConflictResolutionStrategy conflict_resolution_strategy = 10; + + // The properties to write in this mutation. + // None of the properties in the mask may have a reserved name, except for + // `__key__`. + // This field is ignored for `delete`. + // + // If the entity already exists, only properties referenced in the mask are + // updated, others are left untouched. + // Properties referenced in the mask but not in the entity are deleted. + PropertyMask property_mask = 9; + + // Optional. The transforms to perform on the entity. + // + // This field can be set only when the operation is `insert`, `update`, + // or `upsert`. If present, the transforms are be applied to the entity + // regardless of the property mask, in order, after the operation. + repeated PropertyTransform property_transforms = 12 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A transformation of an entity property. +message PropertyTransform { + // 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 properties (same or different entities) + // in a transaction, all the properties will get the same server timestamp. + REQUEST_TIME = 1; + } + + // Optional. The name of the property. + // + // Property paths (a list of property names separated by dots (`.`)) may be + // used to refer to properties inside entity values. For example `foo.bar` + // means the property `bar` inside the entity property `foo`. + // + // If a property name contains a dot `.` or a backlslash `\`, then that name + // must be escaped. + string property = 1 [(google.api.field_behavior) = OPTIONAL]; + + // The transformation to apply to the property. + oneof transform_type { + // Sets the property to the given server value. + ServerValue set_to_server_value = 2; + + // Adds the given value to the property's current value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the given value. + // If either of the given value or the current property value are doubles, + // both values will be interpreted as doubles. Double arithmetic and + // representation of double values follows IEEE 754 semantics. + // If there is positive/negative integer overflow, the property is resolved + // to the largest magnitude positive/negative integer. + Value increment = 3; + + // Sets the property to the maximum of its current value and the given + // value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the given value. + // If a maximum operation is applied where the property and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the property takes on the type of the larger operand. If the operands are + // equivalent (e.g. 3 and 3.0), the property 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 property to the minimum of its current value and the given + // value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the input value. + // If a minimum operation is applied where the property and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the property takes on the type of the smaller operand. If the operands + // are equivalent (e.g. 3 and 3.0), the property 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; + + // Appends the given elements in order if they are not already present in + // the current property value. + // If the property is not an array, or if the property 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 the null value is equal to the null value. + // 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; + + // Removes all of the given elements from the array in the property. + // If the property is not an array, or if the property does not yet exist, + // it is set to the empty array. + // + // Equivalent numbers of 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 the null value is equal to the null value. + // 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 result of applying a mutation. +message MutationResult { + // The automatically allocated key. + // Set only when the mutation allocated a key. + Key key = 3; + + // The version of the entity on the server after processing the mutation. If + // the mutation doesn't change anything on the server, then the version will + // be the version of the current entity or, if no entity is present, a version + // that is strictly greater than the version of any previous entity and less + // than the version of any possible future entity. + int64 version = 4; + + // The create time of the entity. This field will not be set after a 'delete'. + google.protobuf.Timestamp create_time = 7; + + // The update time of the entity on the server after processing the mutation. + // If the mutation doesn't change anything on the server, then the timestamp + // will be the update timestamp of the current entity. This field will not be + // set after a 'delete'. + google.protobuf.Timestamp update_time = 6; + + // Whether a conflict was detected for this mutation. Always false when a + // conflict detection strategy field is not set in the mutation. + bool conflict_detected = 5; + + // The results of applying each + // [PropertyTransform][google.datastore.v1.PropertyTransform], in the same + // order of the request. + repeated Value transform_results = 8; +} + +// The set of arbitrarily nested property paths used to restrict an operation to +// only a subset of properties in an entity. +message PropertyMask { + // The paths to the properties covered by this mask. + // + // A path is a list of property names separated by dots (`.`), for example + // `foo.bar` means the property `bar` inside the entity property `foo` inside + // the entity associated with this path. + // + // If a property name contains a dot `.` or a backslash `\`, then that + // name must be escaped. + // + // A path must not be empty, and may not reference a value inside an + // [array value][google.datastore.v1.Value.array_value]. + repeated string paths = 1; +} + +// The options shared by read requests. +message ReadOptions { + // The possible values for read consistencies. + enum ReadConsistency { + // Unspecified. This value must not be used. + READ_CONSISTENCY_UNSPECIFIED = 0; + + // Strong consistency. + STRONG = 1; + + // Eventual consistency. + EVENTUAL = 2; + } + + // For Cloud Firestore in Datastore mode, if you don't specify + // read_consistency then all lookups and queries default to + // `read_consistency`=`STRONG`. Note that, in Cloud Datastore, global queries + // defaulted to `read_consistency`=`EVENTUAL`. + // + // Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually + // consistent lookups and queries. + oneof consistency_type { + // The non-transactional read consistency to use. + ReadConsistency read_consistency = 1; + + // The identifier of the transaction in which to read. A + // transaction identifier is returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 2; + + // Options for beginning a new transaction for this request. + // + // The new transaction identifier will be returned in the corresponding + // response as either + // [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction] + // or + // [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction]. + TransactionOptions new_transaction = 3; + + // Reads entities as they were at the given time. This value is only + // supported for Cloud Firestore in Datastore mode. + // + // 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; + } +} + +// Options for beginning a new transaction. +// +// Transactions can be created explicitly with calls to +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction] +// or implicitly by setting +// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] +// in read requests. +message TransactionOptions { + // Options specific to read / write transactions. + message ReadWrite { + // The transaction identifier of the transaction being retried. + bytes previous_transaction = 1; + } + + // Options specific to read-only transactions. + message ReadOnly { + // Reads entities 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 = 1; + } + + // The `mode` of the transaction, indicating whether write operations are + // supported. + oneof mode { + // The transaction should allow both reads and writes. + ReadWrite read_write = 1; + + // The transaction should only allow reads. + ReadOnly read_only = 2; + } +} diff --git a/handwritten/nodejs-datastore/protos/google/datastore/v1/entity.proto b/handwritten/nodejs-datastore/protos/google/datastore/v1/entity.proto new file mode 100644 index 00000000000..fdf0a32cb7f --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/v1/entity.proto @@ -0,0 +1,217 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.v1; + +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "EntityProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// A partition ID identifies a grouping of entities. The grouping is always +// by project and namespace, however the namespace ID may be empty. +// +// A partition ID contains several dimensions: +// project ID and namespace ID. +// +// Partition dimensions: +// +// - May be `""`. +// - Must be valid UTF-8 bytes. +// - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}` +// If the value of any dimension matches regex `__.*__`, the partition is +// reserved/read-only. +// A reserved/read-only partition ID is forbidden in certain documented +// contexts. +// +// Foreign partition IDs (in which the project ID does +// not match the context project ID ) are discouraged. +// Reads and writes of foreign partition IDs may fail if the project is not in +// an active state. +message PartitionId { + // The ID of the project to which the entities belong. + string project_id = 2; + + // If not empty, the ID of the database to which the entities + // belong. + string database_id = 3; + + // If not empty, the ID of the namespace to which the entities belong. + string namespace_id = 4; +} + +// A unique identifier for an entity. +// If a key's partition ID or any of its path kinds or names are +// reserved/read-only, the key is reserved/read-only. +// A reserved/read-only key is forbidden in certain documented contexts. +message Key { + // A (kind, ID/name) pair used to construct a key path. + // + // If either name or ID is set, the element is complete. + // If neither is set, the element is incomplete. + message PathElement { + // The kind of the entity. + // + // A kind matching regex `__.*__` is reserved/read-only. + // A kind must not contain more than 1500 bytes when UTF-8 encoded. + // Cannot be `""`. + // + // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are + // encoded as `__bytes__` where `` is the base-64 encoding of the + // bytes. + string kind = 1; + + // The type of ID. + oneof id_type { + // The auto-allocated ID of the entity. + // + // Never equal to zero. Values less than zero are discouraged and may not + // be supported in the future. + int64 id = 2; + + // The name of the entity. + // + // A name matching regex `__.*__` is reserved/read-only. + // A name must not be more than 1500 bytes when UTF-8 encoded. + // Cannot be `""`. + // + // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are + // encoded as `__bytes__` where `` is the base-64 encoding of the + // bytes. + string name = 3; + } + } + + // Entities are partitioned into subsets, currently identified by a project + // ID and namespace ID. + // Queries are scoped to a single partition. + PartitionId partition_id = 1; + + // The entity path. + // An entity path consists of one or more elements composed of a kind and a + // string or numerical identifier, which identify entities. The first + // element identifies a _root entity_, the second element identifies + // a _child_ of the root entity, the third element identifies a child of the + // second entity, and so forth. The entities identified by all prefixes of + // the path are called the element's _ancestors_. + // + // An entity path is always fully complete: *all* of the entity's ancestors + // are required to be in the path along with the entity identifier itself. + // The only exception is that in some documented cases, the identifier in the + // last path element (for the entity) itself may be omitted. For example, + // the last path element of the key of `Mutation.insert` may have no + // identifier. + // + // A path can never be empty, and a path can have at most 100 elements. + repeated PathElement path = 2; +} + +// An array value. +message ArrayValue { + // Values in the array. + // The order of values in an array is preserved as long as all values have + // identical settings for 'exclude_from_indexes'. + repeated Value values = 1; +} + +// A message that can hold any of the supported value types and associated +// metadata. +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. + // When stored in the Datastore, precise only to microseconds; + // any additional precision is rounded down. + google.protobuf.Timestamp timestamp_value = 10; + + // A key value. + Key key_value = 5; + + // A UTF-8 encoded string value. + // When `exclude_from_indexes` is false (it is indexed) , may have at most + // 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes. + string string_value = 17; + + // A blob value. + // May have at most 1,000,000 bytes. + // When `exclude_from_indexes` is false, may have at most 1500 bytes. + // In JSON requests, must be base64-encoded. + bytes blob_value = 18; + + // A geo point value representing a point on the surface of Earth. + google.type.LatLng geo_point_value = 8; + + // An entity value. + // + // - May have no key. + // - May have a key with an incomplete key path. + // - May have a reserved/read-only key. + Entity entity_value = 6; + + // An array value. + // Cannot contain another array value. + // A `Value` instance that sets field `array_value` must not set fields + // `meaning` or `exclude_from_indexes`. + ArrayValue array_value = 9; + } + + // The `meaning` field should only be populated for backwards compatibility. + int32 meaning = 14; + + // If the value should be excluded from all indexes including those defined + // explicitly. + bool exclude_from_indexes = 19; +} + +// A Datastore data object. +// +// Must not exceed 1 MiB - 4 bytes. +message Entity { + // The entity's key. + // + // An entity must have a key, unless otherwise documented (for example, + // an entity in `Value.entity_value` may have no key). + // An entity's kind is its key path's last element's kind, + // or null if it has no key. + Key key = 1; + + // The entity's properties. + // The map's keys are property names. + // A property name matching regex `__.*__` is reserved. + // A reserved property name is forbidden in certain documented contexts. + // The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot + // be empty. + map properties = 3; +} diff --git a/handwritten/nodejs-datastore/protos/google/datastore/v1/query.proto b/handwritten/nodejs-datastore/protos/google/datastore/v1/query.proto new file mode 100644 index 00000000000..2e36f958b67 --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/v1/query.proto @@ -0,0 +1,622 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.v1; + +import "google/api/field_behavior.proto"; +import "google/datastore/v1/entity.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// The result of fetching an entity from Datastore. +message EntityResult { + // Specifies what data the 'entity' field contains. + // A `ResultType` is either implied (for example, in `LookupResponse.missing` + // from `datastore.proto`, it is always `KEY_ONLY`) or specified by context + // (for example, in message `QueryResultBatch`, field `entity_result_type` + // specifies a `ResultType` for all the values in field `entity_results`). + enum ResultType { + // Unspecified. This value is never used. + RESULT_TYPE_UNSPECIFIED = 0; + + // The key and properties. + FULL = 1; + + // A projected subset of properties. The entity may have no key. + PROJECTION = 2; + + // Only the key. + KEY_ONLY = 3; + } + + // The resulting entity. + Entity entity = 1; + + // The version of the entity, a strictly positive number that monotonically + // increases with changes to the entity. + // + // This field is set for + // [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results. + // + // For [missing][google.datastore.v1.LookupResponse.missing] entities in + // `LookupResponse`, this is the version of the snapshot that was used to look + // up the entity, and it is always set except for eventually consistent reads. + int64 version = 4; + + // The time at which the entity was created. + // This field is set for + // [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results. + // If this entity is missing, this field will not be set. + google.protobuf.Timestamp create_time = 6; + + // The time at which the entity was last changed. + // This field is set for + // [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results. + // If this entity is missing, this field will not be set. + google.protobuf.Timestamp update_time = 5; + + // A cursor that points to the position after the result entity. + // Set only when the `EntityResult` is part of a `QueryResultBatch` message. + bytes cursor = 3; +} + +// A query for entities. +// +// The query stages are executed in the following order: +// 1. kind +// 2. filter +// 3. projection +// 4. order + start_cursor + end_cursor +// 5. offset +// 6. limit +// 7. find_nearest +message Query { + // The projection to return. Defaults to returning all properties. + repeated Projection projection = 2; + + // The kinds to query (if empty, returns entities of all kinds). + // Currently at most 1 kind may be specified. + repeated KindExpression kind = 3; + + // The filter to apply. + Filter filter = 4; + + // The order to apply to the query results (if empty, order is unspecified). + repeated PropertyOrder order = 5; + + // The properties to make distinct. The query results will contain the first + // result for each distinct combination of values for the given properties + // (if empty, all results are returned). + // + // Requires: + // + // * If `order` is specified, the set of distinct on properties must appear + // before the non-distinct on properties in `order`. + repeated PropertyReference distinct_on = 6; + + // A starting point for the query results. Query cursors are + // returned in query result batches and + // [can only be used to continue the same + // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). + bytes start_cursor = 7; + + // An ending point for the query results. Query cursors are + // returned in query result batches and + // [can only be used to limit the same + // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). + bytes end_cursor = 8; + + // The number of results to skip. Applies before limit, but after all other + // constraints. Optional. Must be >= 0 if specified. + int32 offset = 10; + + // The maximum number of results to return. Applies after all other + // constraints. Optional. + // Unspecified is interpreted as no limit. + // Must be >= 0 if specified. + google.protobuf.Int32Value limit = 12; + + // Optional. A potential Nearest Neighbors Search. + // + // Applies after all other filters and ordering. + // + // Finds the closest vector embeddings to the given query vector. + FindNearest find_nearest = 13 [(google.api.field_behavior) = OPTIONAL]; +} + +// Datastore query for running an aggregation over a +// [Query][google.datastore.v1.Query]. +message AggregationQuery { + // Defines an aggregation that produces a single result. + message Aggregation { + // Count of entities that match the query. + // + // The `COUNT(*)` aggregation function operates on the entire entity + // so it does not require a field reference. + message Count { + // Optional. Optional constraint on the maximum number of entities to + // count. + // + // This provides a way to set an upper bound on the number of entities + // to scan, limiting latency, and cost. + // + // Unspecified is interpreted as no bound. + // + // If a zero value is provided, a count result of zero should always be + // expected. + // + // High-Level Example: + // + // ``` + // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); + // ``` + // + // Requires: + // + // * Must be non-negative when present. + google.protobuf.Int64Value up_to = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Sum of the values of the requested property. + // + // * 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 property to aggregate on. + PropertyReference property = 1; + } + + // Average of the values of the requested property. + // + // * 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 property to aggregate on. + PropertyReference property = 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 property to store the result of the + // aggregation. + // + // If not provided, Datastore will pick a default name following the format + // `property_`. 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 property_1, + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) AS property_2 + // OVER ( + // ... + // ); + // ``` + // + // Requires: + // + // * Must be unique across all aggregation aliases. + // * Conform to [entity property + // name][google.datastore.v1.Entity.properties] limitations. + string alias = 7 [(google.api.field_behavior) = OPTIONAL]; + } + + // The base query to aggregate over. + oneof query_type { + // Nested query for aggregation + Query nested_query = 1; + } + + // Optional. Series of aggregations to apply over the results of the + // `nested_query`. + // + // Requires: + // + // * A minimum of one and maximum of five aggregations per query. + repeated Aggregation aggregations = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A representation of a kind. +message KindExpression { + // The name of the kind. + string name = 1; +} + +// A reference to a property relative to the kind expressions. +message PropertyReference { + // A reference to a property. + // + // Requires: + // + // * MUST be a dot-delimited (`.`) string of segments, where each segment + // conforms to [entity property name][google.datastore.v1.Entity.properties] + // limitations. + string name = 2; +} + +// A representation of a property in a projection. +message Projection { + // The property to project. + PropertyReference property = 1; +} + +// The desired order for a specific property. +message PropertyOrder { + // The sort direction. + enum Direction { + // Unspecified. This value must not be used. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + + // The property to order by. + PropertyReference property = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; +} + +// A holder for any type of filter. +message Filter { + // The type of filter. + oneof filter_type { + // A composite filter. + CompositeFilter composite_filter = 1; + + // A filter on a property. + PropertyFilter property_filter = 2; + } +} + +// 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; + + // 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 property. +message PropertyFilter { + // A property filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `property` is less than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + LESS_THAN = 1; + + // The given `property` is less than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + LESS_THAN_OR_EQUAL = 2; + + // The given `property` is greater than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + GREATER_THAN = 3; + + // The given `property` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + GREATER_THAN_OR_EQUAL = 4; + + // The given `property` is equal to the given `value`. + EQUAL = 5; + + // The given `property` 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` is in the same query. + IN = 6; + + // The given `property` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL` or `NOT_IN` is in the same query. + // * That `property` comes first in the `order_by`. + NOT_EQUAL = 9; + + // Limit the result set to the given entity and its descendants. + // + // Requires: + // + // * That `value` is an entity key. + // * All evaluated disjunctions must have the same `HAS_ANCESTOR` filter. + HAS_ANCESTOR = 11; + + // The value of the `property` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `OR`, `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query. + // * That `field` comes first in the `order_by`. + NOT_IN = 13; + } + + // The property to filter by. + PropertyReference property = 1; + + // The operator to filter by. + Operator op = 2; + + // The value to compare the property to. + Value value = 3; +} + +// Nearest Neighbors search config. The ordering provided by FindNearest +// supersedes the order_by stage. If multiple documents have the same vector +// distance, the returned document order is not guaranteed to be stable between +// queries. +message FindNearest { + // The distance measure to use when comparing vectors. + enum DistanceMeasure { + // Should not be set. + DISTANCE_MEASURE_UNSPECIFIED = 0; + + // Measures the EUCLIDEAN distance between the vectors. See + // [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn + // more. The resulting distance decreases the more similar two vectors are. + EUCLIDEAN = 1; + + // COSINE distance compares vectors based on the angle between them, which + // allows you to measure similarity that isn't based on the vectors + // magnitude. We recommend using DOT_PRODUCT with unit normalized vectors + // instead of COSINE distance, which is mathematically equivalent with + // better performance. See [Cosine + // Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn + // more about COSINE similarity and COSINE distance. The resulting COSINE + // distance decreases the more similar two vectors are. + COSINE = 2; + + // Similar to cosine but is affected by the magnitude of the vectors. See + // [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more. + // The resulting distance increases the more similar two vectors are. + DOT_PRODUCT = 3; + } + + // Required. An indexed vector property to search upon. Only documents which + // contain vectors whose dimensionality match the query_vector can be + // returned. + PropertyReference vector_property = 1 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The query vector that we are searching on. Must be a vector of no + // more than 2048 dimensions. + Value query_vector = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The Distance Measure to use, required. + DistanceMeasure distance_measure = 3 [(google.api.field_behavior) = REQUIRED]; + + // Required. The number of nearest neighbors to return. Must be a positive + // integer of no more than 100. + google.protobuf.Int32Value limit = 4 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Optional name of the field to output the result of the vector + // distance calculation. Must conform to [entity + // property][google.datastore.v1.Entity.properties] limitations. + string distance_result_property = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Option to specify a threshold for which no less similar documents + // will be returned. The behavior of the specified `distance_measure` will + // affect the meaning of the distance threshold. Since DOT_PRODUCT distances + // increase when the vectors are more similar, the comparison is inverted. + // + // For EUCLIDEAN, COSINE: WHERE distance <= distance_threshold + // For DOT_PRODUCT: WHERE distance >= distance_threshold + google.protobuf.DoubleValue distance_threshold = 6 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A [GQL +// query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). +message GqlQuery { + // A string of the format described + // [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). + string query_string = 1; + + // When false, the query string must not contain any literals and instead must + // bind all values. For example, + // `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while + // `SELECT * FROM Kind WHERE a = @value` is. + bool allow_literals = 2; + + // For each non-reserved named binding site in the query string, there must be + // a named parameter with that name, but not necessarily the inverse. + // + // Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex + // `__.*__`, and must not be `""`. + map named_bindings = 5; + + // Numbered binding site @1 references the first numbered parameter, + // effectively using 1-based indexing, rather than the usual 0. + // + // For each binding site numbered i in `query_string`, there must be an i-th + // numbered parameter. The inverse must also be true. + repeated GqlQueryParameter positional_bindings = 4; +} + +// A binding parameter for a GQL query. +message GqlQueryParameter { + // The type of parameter. + oneof parameter_type { + // A value parameter. + Value value = 2; + + // A query cursor. Query cursors are returned in query + // result batches. + bytes cursor = 3; + } +} + +// A batch of results produced by a query. +message QueryResultBatch { + // The possible values for the `more_results` field. + enum MoreResultsType { + // Unspecified. This value is never used. + MORE_RESULTS_TYPE_UNSPECIFIED = 0; + + // There may be additional batches to fetch from this query. + NOT_FINISHED = 1; + + // The query is finished, but there may be more results after the limit. + MORE_RESULTS_AFTER_LIMIT = 2; + + // The query is finished, but there may be more results after the end + // cursor. + MORE_RESULTS_AFTER_CURSOR = 4; + + // The query is finished, and there are no more results. + NO_MORE_RESULTS = 3; + } + + // The number of results skipped, typically because of an offset. + int32 skipped_results = 6; + + // A cursor that points to the position after the last skipped result. + // Will be set when `skipped_results` != 0. + bytes skipped_cursor = 3; + + // The result type for every entity in `entity_results`. + EntityResult.ResultType entity_result_type = 1; + + // The results for this batch. + repeated EntityResult entity_results = 2; + + // A cursor that points to the position after the last result in the batch. + bytes end_cursor = 4; + + // The state of the query after the current batch. + MoreResultsType more_results = 5; + + // The version number of the snapshot this batch was returned from. + // This applies to the range of results from the query's `start_cursor` (or + // the beginning of the query if no cursor was given) to this batch's + // `end_cursor` (not the query's `end_cursor`). + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater snapshot version number. Each batch's snapshot version + // is valid for all preceding batches. + // The value will be zero for eventually consistent queries. + int64 snapshot_version = 7; + + // Read timestamp this batch was returned from. + // This applies to the range of results from the query's `start_cursor` (or + // the beginning of the query if no cursor was given) to this batch's + // `end_cursor` (not the query's `end_cursor`). + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater timestamp. Each batch's read timestamp + // is valid for all preceding batches. + // This value will not be set for eventually consistent queries in Cloud + // Datastore. + google.protobuf.Timestamp read_time = 8; +} diff --git a/handwritten/nodejs-datastore/protos/google/datastore/v1/query_profile.proto b/handwritten/nodejs-datastore/protos/google/datastore/v1/query_profile.proto new file mode 100644 index 00000000000..71a4eb59933 --- /dev/null +++ b/handwritten/nodejs-datastore/protos/google/datastore/v1/query_profile.proto @@ -0,0 +1,91 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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.datastore.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProfileProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// Specification of the Datastore Query Profile fields. + +// Explain options for the query. +message ExplainOptions { + // Optional. Whether to execute this query. + // + // When false (the default), the query will be planned, returning only + // metrics from the planning stages. + // + // When true, the query will be planned and executed, returning the full + // query results along with both planning and execution stage metrics. + bool analyze = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// Explain metrics for the query. +message ExplainMetrics { + // Planning phase information for the query. + PlanSummary plan_summary = 1; + + // Aggregated stats from the execution of the query. Only present when + // [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set + // to true. + ExecutionStats execution_stats = 2; +} + +// Planning phase information for the query. +message PlanSummary { + // The indexes selected for the query. For example: + // [ + // {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, + // {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} + // ] + repeated google.protobuf.Struct indexes_used = 1; +} + +// Execution statistics for the query. +message ExecutionStats { + // Total number of results returned, including documents, projections, + // aggregation results, keys. + int64 results_returned = 1; + + // Total time to execute the query in the backend. + google.protobuf.Duration execution_duration = 3; + + // Total billable read operations. + int64 read_operations = 4; + + // Debugging statistics from the execution of the query. Note that the + // debugging stats are subject to change as Firestore evolves. It could + // include: + // { + // "indexes_entries_scanned": "1000", + // "documents_scanned": "20", + // "billing_details" : { + // "documents_billable": "20", + // "index_entries_billable": "1000", + // "min_query_cost": "0" + // } + // } + google.protobuf.Struct debug_stats = 5; +} diff --git a/handwritten/nodejs-datastore/protos/protos.d.ts b/handwritten/nodejs-datastore/protos/protos.d.ts new file mode 100644 index 00000000000..33ec9fcd7a0 --- /dev/null +++ b/handwritten/nodejs-datastore/protos/protos.d.ts @@ -0,0 +1,18362 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import type {protobuf as $protobuf} from "google-gax"; +import Long = require("long"); +/** Namespace google. */ +export namespace google { + + /** Namespace datastore. */ + namespace datastore { + + /** Namespace admin. */ + namespace admin { + + /** Namespace v1. */ + namespace v1 { + + /** Represents a DatastoreAdmin */ + class DatastoreAdmin extends $protobuf.rpc.Service { + + /** + * Constructs a new DatastoreAdmin service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new DatastoreAdmin service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): DatastoreAdmin; + + /** + * Calls ExportEntities. + * @param request ExportEntitiesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public exportEntities(request: google.datastore.admin.v1.IExportEntitiesRequest, callback: google.datastore.admin.v1.DatastoreAdmin.ExportEntitiesCallback): void; + + /** + * Calls ExportEntities. + * @param request ExportEntitiesRequest message or plain object + * @returns Promise + */ + public exportEntities(request: google.datastore.admin.v1.IExportEntitiesRequest): Promise; + + /** + * Calls ImportEntities. + * @param request ImportEntitiesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public importEntities(request: google.datastore.admin.v1.IImportEntitiesRequest, callback: google.datastore.admin.v1.DatastoreAdmin.ImportEntitiesCallback): void; + + /** + * Calls ImportEntities. + * @param request ImportEntitiesRequest message or plain object + * @returns Promise + */ + public importEntities(request: google.datastore.admin.v1.IImportEntitiesRequest): Promise; + + /** + * Calls CreateIndex. + * @param request CreateIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public createIndex(request: google.datastore.admin.v1.ICreateIndexRequest, callback: google.datastore.admin.v1.DatastoreAdmin.CreateIndexCallback): void; + + /** + * Calls CreateIndex. + * @param request CreateIndexRequest message or plain object + * @returns Promise + */ + public createIndex(request: google.datastore.admin.v1.ICreateIndexRequest): Promise; + + /** + * Calls DeleteIndex. + * @param request DeleteIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public deleteIndex(request: google.datastore.admin.v1.IDeleteIndexRequest, callback: google.datastore.admin.v1.DatastoreAdmin.DeleteIndexCallback): void; + + /** + * Calls DeleteIndex. + * @param request DeleteIndexRequest message or plain object + * @returns Promise + */ + public deleteIndex(request: google.datastore.admin.v1.IDeleteIndexRequest): Promise; + + /** + * Calls GetIndex. + * @param request GetIndexRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Index + */ + public getIndex(request: google.datastore.admin.v1.IGetIndexRequest, callback: google.datastore.admin.v1.DatastoreAdmin.GetIndexCallback): void; + + /** + * Calls GetIndex. + * @param request GetIndexRequest message or plain object + * @returns Promise + */ + public getIndex(request: google.datastore.admin.v1.IGetIndexRequest): Promise; + + /** + * Calls ListIndexes. + * @param request ListIndexesRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListIndexesResponse + */ + public listIndexes(request: google.datastore.admin.v1.IListIndexesRequest, callback: google.datastore.admin.v1.DatastoreAdmin.ListIndexesCallback): void; + + /** + * Calls ListIndexes. + * @param request ListIndexesRequest message or plain object + * @returns Promise + */ + public listIndexes(request: google.datastore.admin.v1.IListIndexesRequest): Promise; + } + + namespace DatastoreAdmin { + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|exportEntities}. + * @param error Error, if any + * @param [response] Operation + */ + type ExportEntitiesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|importEntities}. + * @param error Error, if any + * @param [response] Operation + */ + type ImportEntitiesCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|createIndex}. + * @param error Error, if any + * @param [response] Operation + */ + type CreateIndexCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|deleteIndex}. + * @param error Error, if any + * @param [response] Operation + */ + type DeleteIndexCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|getIndex}. + * @param error Error, if any + * @param [response] Index + */ + type GetIndexCallback = (error: (Error|null), response?: google.datastore.admin.v1.Index) => void; + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|listIndexes}. + * @param error Error, if any + * @param [response] ListIndexesResponse + */ + type ListIndexesCallback = (error: (Error|null), response?: google.datastore.admin.v1.ListIndexesResponse) => void; + } + + /** Properties of a CommonMetadata. */ + interface ICommonMetadata { + + /** CommonMetadata startTime */ + startTime?: (google.protobuf.ITimestamp|null); + + /** CommonMetadata endTime */ + endTime?: (google.protobuf.ITimestamp|null); + + /** CommonMetadata operationType */ + operationType?: (google.datastore.admin.v1.OperationType|keyof typeof google.datastore.admin.v1.OperationType|null); + + /** CommonMetadata labels */ + labels?: ({ [k: string]: string }|null); + + /** CommonMetadata state */ + state?: (google.datastore.admin.v1.CommonMetadata.State|keyof typeof google.datastore.admin.v1.CommonMetadata.State|null); + } + + /** Represents a CommonMetadata. */ + class CommonMetadata implements ICommonMetadata { + + /** + * Constructs a new CommonMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.ICommonMetadata); + + /** CommonMetadata startTime. */ + public startTime?: (google.protobuf.ITimestamp|null); + + /** CommonMetadata endTime. */ + public endTime?: (google.protobuf.ITimestamp|null); + + /** CommonMetadata operationType. */ + public operationType: (google.datastore.admin.v1.OperationType|keyof typeof google.datastore.admin.v1.OperationType); + + /** CommonMetadata labels. */ + public labels: { [k: string]: string }; + + /** CommonMetadata state. */ + public state: (google.datastore.admin.v1.CommonMetadata.State|keyof typeof google.datastore.admin.v1.CommonMetadata.State); + + /** + * Creates a new CommonMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns CommonMetadata instance + */ + public static create(properties?: google.datastore.admin.v1.ICommonMetadata): google.datastore.admin.v1.CommonMetadata; + + /** + * Encodes the specified CommonMetadata message. Does not implicitly {@link google.datastore.admin.v1.CommonMetadata.verify|verify} messages. + * @param message CommonMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.ICommonMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CommonMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.CommonMetadata.verify|verify} messages. + * @param message CommonMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.ICommonMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommonMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CommonMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.CommonMetadata; + + /** + * Decodes a CommonMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CommonMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.CommonMetadata; + + /** + * Verifies a CommonMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CommonMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommonMetadata + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.CommonMetadata; + + /** + * Creates a plain object from a CommonMetadata message. Also converts values to other types if specified. + * @param message CommonMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.CommonMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommonMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CommonMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CommonMetadata { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + INITIALIZING = 1, + PROCESSING = 2, + CANCELLING = 3, + FINALIZING = 4, + SUCCESSFUL = 5, + FAILED = 6, + CANCELLED = 7 + } + } + + /** Properties of a Progress. */ + interface IProgress { + + /** Progress workCompleted */ + workCompleted?: (number|Long|string|null); + + /** Progress workEstimated */ + workEstimated?: (number|Long|string|null); + } + + /** Represents a Progress. */ + class Progress implements IProgress { + + /** + * Constructs a new Progress. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IProgress); + + /** Progress workCompleted. */ + public workCompleted: (number|Long|string); + + /** Progress workEstimated. */ + public workEstimated: (number|Long|string); + + /** + * Creates a new Progress instance using the specified properties. + * @param [properties] Properties to set + * @returns Progress instance + */ + public static create(properties?: google.datastore.admin.v1.IProgress): google.datastore.admin.v1.Progress; + + /** + * Encodes the specified Progress message. Does not implicitly {@link google.datastore.admin.v1.Progress.verify|verify} messages. + * @param message Progress message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IProgress, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Progress message, length delimited. Does not implicitly {@link google.datastore.admin.v1.Progress.verify|verify} messages. + * @param message Progress message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IProgress, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Progress message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Progress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.Progress; + + /** + * Decodes a Progress message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Progress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.Progress; + + /** + * Verifies a Progress message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Progress message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Progress + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.Progress; + + /** + * Creates a plain object from a Progress message. Also converts values to other types if specified. + * @param message Progress + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.Progress, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Progress to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Progress + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportEntitiesRequest. */ + interface IExportEntitiesRequest { + + /** ExportEntitiesRequest projectId */ + projectId?: (string|null); + + /** ExportEntitiesRequest labels */ + labels?: ({ [k: string]: string }|null); + + /** ExportEntitiesRequest entityFilter */ + entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + + /** ExportEntitiesRequest outputUrlPrefix */ + outputUrlPrefix?: (string|null); + } + + /** Represents an ExportEntitiesRequest. */ + class ExportEntitiesRequest implements IExportEntitiesRequest { + + /** + * Constructs a new ExportEntitiesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IExportEntitiesRequest); + + /** ExportEntitiesRequest projectId. */ + public projectId: string; + + /** ExportEntitiesRequest labels. */ + public labels: { [k: string]: string }; + + /** ExportEntitiesRequest entityFilter. */ + public entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + + /** ExportEntitiesRequest outputUrlPrefix. */ + public outputUrlPrefix: string; + + /** + * Creates a new ExportEntitiesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportEntitiesRequest instance + */ + public static create(properties?: google.datastore.admin.v1.IExportEntitiesRequest): google.datastore.admin.v1.ExportEntitiesRequest; + + /** + * Encodes the specified ExportEntitiesRequest message. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesRequest.verify|verify} messages. + * @param message ExportEntitiesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IExportEntitiesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportEntitiesRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesRequest.verify|verify} messages. + * @param message ExportEntitiesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IExportEntitiesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportEntitiesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.ExportEntitiesRequest; + + /** + * Decodes an ExportEntitiesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.ExportEntitiesRequest; + + /** + * Verifies an ExportEntitiesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExportEntitiesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportEntitiesRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.ExportEntitiesRequest; + + /** + * Creates a plain object from an ExportEntitiesRequest message. Also converts values to other types if specified. + * @param message ExportEntitiesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.ExportEntitiesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportEntitiesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportEntitiesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportEntitiesRequest. */ + interface IImportEntitiesRequest { + + /** ImportEntitiesRequest projectId */ + projectId?: (string|null); + + /** ImportEntitiesRequest labels */ + labels?: ({ [k: string]: string }|null); + + /** ImportEntitiesRequest inputUrl */ + inputUrl?: (string|null); + + /** ImportEntitiesRequest entityFilter */ + entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + } + + /** Represents an ImportEntitiesRequest. */ + class ImportEntitiesRequest implements IImportEntitiesRequest { + + /** + * Constructs a new ImportEntitiesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IImportEntitiesRequest); + + /** ImportEntitiesRequest projectId. */ + public projectId: string; + + /** ImportEntitiesRequest labels. */ + public labels: { [k: string]: string }; + + /** ImportEntitiesRequest inputUrl. */ + public inputUrl: string; + + /** ImportEntitiesRequest entityFilter. */ + public entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + + /** + * Creates a new ImportEntitiesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportEntitiesRequest instance + */ + public static create(properties?: google.datastore.admin.v1.IImportEntitiesRequest): google.datastore.admin.v1.ImportEntitiesRequest; + + /** + * Encodes the specified ImportEntitiesRequest message. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesRequest.verify|verify} messages. + * @param message ImportEntitiesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IImportEntitiesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportEntitiesRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesRequest.verify|verify} messages. + * @param message ImportEntitiesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IImportEntitiesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportEntitiesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.ImportEntitiesRequest; + + /** + * Decodes an ImportEntitiesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.ImportEntitiesRequest; + + /** + * Verifies an ImportEntitiesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ImportEntitiesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportEntitiesRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.ImportEntitiesRequest; + + /** + * Creates a plain object from an ImportEntitiesRequest message. Also converts values to other types if specified. + * @param message ImportEntitiesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.ImportEntitiesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportEntitiesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportEntitiesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportEntitiesResponse. */ + interface IExportEntitiesResponse { + + /** ExportEntitiesResponse outputUrl */ + outputUrl?: (string|null); + } + + /** Represents an ExportEntitiesResponse. */ + class ExportEntitiesResponse implements IExportEntitiesResponse { + + /** + * Constructs a new ExportEntitiesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IExportEntitiesResponse); + + /** ExportEntitiesResponse outputUrl. */ + public outputUrl: string; + + /** + * Creates a new ExportEntitiesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportEntitiesResponse instance + */ + public static create(properties?: google.datastore.admin.v1.IExportEntitiesResponse): google.datastore.admin.v1.ExportEntitiesResponse; + + /** + * Encodes the specified ExportEntitiesResponse message. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesResponse.verify|verify} messages. + * @param message ExportEntitiesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IExportEntitiesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportEntitiesResponse message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesResponse.verify|verify} messages. + * @param message ExportEntitiesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IExportEntitiesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportEntitiesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportEntitiesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.ExportEntitiesResponse; + + /** + * Decodes an ExportEntitiesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportEntitiesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.ExportEntitiesResponse; + + /** + * Verifies an ExportEntitiesResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExportEntitiesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportEntitiesResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.ExportEntitiesResponse; + + /** + * Creates a plain object from an ExportEntitiesResponse message. Also converts values to other types if specified. + * @param message ExportEntitiesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.ExportEntitiesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportEntitiesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportEntitiesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExportEntitiesMetadata. */ + interface IExportEntitiesMetadata { + + /** ExportEntitiesMetadata common */ + common?: (google.datastore.admin.v1.ICommonMetadata|null); + + /** ExportEntitiesMetadata progressEntities */ + progressEntities?: (google.datastore.admin.v1.IProgress|null); + + /** ExportEntitiesMetadata progressBytes */ + progressBytes?: (google.datastore.admin.v1.IProgress|null); + + /** ExportEntitiesMetadata entityFilter */ + entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + + /** ExportEntitiesMetadata outputUrlPrefix */ + outputUrlPrefix?: (string|null); + } + + /** Represents an ExportEntitiesMetadata. */ + class ExportEntitiesMetadata implements IExportEntitiesMetadata { + + /** + * Constructs a new ExportEntitiesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IExportEntitiesMetadata); + + /** ExportEntitiesMetadata common. */ + public common?: (google.datastore.admin.v1.ICommonMetadata|null); + + /** ExportEntitiesMetadata progressEntities. */ + public progressEntities?: (google.datastore.admin.v1.IProgress|null); + + /** ExportEntitiesMetadata progressBytes. */ + public progressBytes?: (google.datastore.admin.v1.IProgress|null); + + /** ExportEntitiesMetadata entityFilter. */ + public entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + + /** ExportEntitiesMetadata outputUrlPrefix. */ + public outputUrlPrefix: string; + + /** + * Creates a new ExportEntitiesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ExportEntitiesMetadata instance + */ + public static create(properties?: google.datastore.admin.v1.IExportEntitiesMetadata): google.datastore.admin.v1.ExportEntitiesMetadata; + + /** + * Encodes the specified ExportEntitiesMetadata message. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesMetadata.verify|verify} messages. + * @param message ExportEntitiesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IExportEntitiesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExportEntitiesMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesMetadata.verify|verify} messages. + * @param message ExportEntitiesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IExportEntitiesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExportEntitiesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.ExportEntitiesMetadata; + + /** + * Decodes an ExportEntitiesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.ExportEntitiesMetadata; + + /** + * Verifies an ExportEntitiesMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExportEntitiesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExportEntitiesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.ExportEntitiesMetadata; + + /** + * Creates a plain object from an ExportEntitiesMetadata message. Also converts values to other types if specified. + * @param message ExportEntitiesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.ExportEntitiesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExportEntitiesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExportEntitiesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ImportEntitiesMetadata. */ + interface IImportEntitiesMetadata { + + /** ImportEntitiesMetadata common */ + common?: (google.datastore.admin.v1.ICommonMetadata|null); + + /** ImportEntitiesMetadata progressEntities */ + progressEntities?: (google.datastore.admin.v1.IProgress|null); + + /** ImportEntitiesMetadata progressBytes */ + progressBytes?: (google.datastore.admin.v1.IProgress|null); + + /** ImportEntitiesMetadata entityFilter */ + entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + + /** ImportEntitiesMetadata inputUrl */ + inputUrl?: (string|null); + } + + /** Represents an ImportEntitiesMetadata. */ + class ImportEntitiesMetadata implements IImportEntitiesMetadata { + + /** + * Constructs a new ImportEntitiesMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IImportEntitiesMetadata); + + /** ImportEntitiesMetadata common. */ + public common?: (google.datastore.admin.v1.ICommonMetadata|null); + + /** ImportEntitiesMetadata progressEntities. */ + public progressEntities?: (google.datastore.admin.v1.IProgress|null); + + /** ImportEntitiesMetadata progressBytes. */ + public progressBytes?: (google.datastore.admin.v1.IProgress|null); + + /** ImportEntitiesMetadata entityFilter. */ + public entityFilter?: (google.datastore.admin.v1.IEntityFilter|null); + + /** ImportEntitiesMetadata inputUrl. */ + public inputUrl: string; + + /** + * Creates a new ImportEntitiesMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns ImportEntitiesMetadata instance + */ + public static create(properties?: google.datastore.admin.v1.IImportEntitiesMetadata): google.datastore.admin.v1.ImportEntitiesMetadata; + + /** + * Encodes the specified ImportEntitiesMetadata message. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesMetadata.verify|verify} messages. + * @param message ImportEntitiesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IImportEntitiesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ImportEntitiesMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesMetadata.verify|verify} messages. + * @param message ImportEntitiesMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IImportEntitiesMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ImportEntitiesMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ImportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.ImportEntitiesMetadata; + + /** + * Decodes an ImportEntitiesMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ImportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.ImportEntitiesMetadata; + + /** + * Verifies an ImportEntitiesMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ImportEntitiesMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ImportEntitiesMetadata + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.ImportEntitiesMetadata; + + /** + * Creates a plain object from an ImportEntitiesMetadata message. Also converts values to other types if specified. + * @param message ImportEntitiesMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.ImportEntitiesMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ImportEntitiesMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ImportEntitiesMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an EntityFilter. */ + interface IEntityFilter { + + /** EntityFilter kinds */ + kinds?: (string[]|null); + + /** EntityFilter namespaceIds */ + namespaceIds?: (string[]|null); + } + + /** Represents an EntityFilter. */ + class EntityFilter implements IEntityFilter { + + /** + * Constructs a new EntityFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IEntityFilter); + + /** EntityFilter kinds. */ + public kinds: string[]; + + /** EntityFilter namespaceIds. */ + public namespaceIds: string[]; + + /** + * Creates a new EntityFilter instance using the specified properties. + * @param [properties] Properties to set + * @returns EntityFilter instance + */ + public static create(properties?: google.datastore.admin.v1.IEntityFilter): google.datastore.admin.v1.EntityFilter; + + /** + * Encodes the specified EntityFilter message. Does not implicitly {@link google.datastore.admin.v1.EntityFilter.verify|verify} messages. + * @param message EntityFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IEntityFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EntityFilter message, length delimited. Does not implicitly {@link google.datastore.admin.v1.EntityFilter.verify|verify} messages. + * @param message EntityFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IEntityFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EntityFilter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EntityFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.EntityFilter; + + /** + * Decodes an EntityFilter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EntityFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.EntityFilter; + + /** + * Verifies an EntityFilter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EntityFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EntityFilter + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.EntityFilter; + + /** + * Creates a plain object from an EntityFilter message. Also converts values to other types if specified. + * @param message EntityFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.EntityFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EntityFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EntityFilter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CreateIndexRequest. */ + interface ICreateIndexRequest { + + /** CreateIndexRequest projectId */ + projectId?: (string|null); + + /** CreateIndexRequest index */ + index?: (google.datastore.admin.v1.IIndex|null); + } + + /** Represents a CreateIndexRequest. */ + class CreateIndexRequest implements ICreateIndexRequest { + + /** + * Constructs a new CreateIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.ICreateIndexRequest); + + /** CreateIndexRequest projectId. */ + public projectId: string; + + /** CreateIndexRequest index. */ + public index?: (google.datastore.admin.v1.IIndex|null); + + /** + * Creates a new CreateIndexRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateIndexRequest instance + */ + public static create(properties?: google.datastore.admin.v1.ICreateIndexRequest): google.datastore.admin.v1.CreateIndexRequest; + + /** + * Encodes the specified CreateIndexRequest message. Does not implicitly {@link google.datastore.admin.v1.CreateIndexRequest.verify|verify} messages. + * @param message CreateIndexRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.ICreateIndexRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateIndexRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.CreateIndexRequest.verify|verify} messages. + * @param message CreateIndexRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.ICreateIndexRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateIndexRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.CreateIndexRequest; + + /** + * Decodes a CreateIndexRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.CreateIndexRequest; + + /** + * Verifies a CreateIndexRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.CreateIndexRequest; + + /** + * Creates a plain object from a CreateIndexRequest message. Also converts values to other types if specified. + * @param message CreateIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.CreateIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateIndexRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteIndexRequest. */ + interface IDeleteIndexRequest { + + /** DeleteIndexRequest projectId */ + projectId?: (string|null); + + /** DeleteIndexRequest indexId */ + indexId?: (string|null); + } + + /** Represents a DeleteIndexRequest. */ + class DeleteIndexRequest implements IDeleteIndexRequest { + + /** + * Constructs a new DeleteIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IDeleteIndexRequest); + + /** DeleteIndexRequest projectId. */ + public projectId: string; + + /** DeleteIndexRequest indexId. */ + public indexId: string; + + /** + * Creates a new DeleteIndexRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteIndexRequest instance + */ + public static create(properties?: google.datastore.admin.v1.IDeleteIndexRequest): google.datastore.admin.v1.DeleteIndexRequest; + + /** + * Encodes the specified DeleteIndexRequest message. Does not implicitly {@link google.datastore.admin.v1.DeleteIndexRequest.verify|verify} messages. + * @param message DeleteIndexRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IDeleteIndexRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteIndexRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.DeleteIndexRequest.verify|verify} messages. + * @param message DeleteIndexRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IDeleteIndexRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteIndexRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.DeleteIndexRequest; + + /** + * Decodes a DeleteIndexRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.DeleteIndexRequest; + + /** + * Verifies a DeleteIndexRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.DeleteIndexRequest; + + /** + * Creates a plain object from a DeleteIndexRequest message. Also converts values to other types if specified. + * @param message DeleteIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.DeleteIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteIndexRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetIndexRequest. */ + interface IGetIndexRequest { + + /** GetIndexRequest projectId */ + projectId?: (string|null); + + /** GetIndexRequest indexId */ + indexId?: (string|null); + } + + /** Represents a GetIndexRequest. */ + class GetIndexRequest implements IGetIndexRequest { + + /** + * Constructs a new GetIndexRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IGetIndexRequest); + + /** GetIndexRequest projectId. */ + public projectId: string; + + /** GetIndexRequest indexId. */ + public indexId: string; + + /** + * Creates a new GetIndexRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetIndexRequest instance + */ + public static create(properties?: google.datastore.admin.v1.IGetIndexRequest): google.datastore.admin.v1.GetIndexRequest; + + /** + * Encodes the specified GetIndexRequest message. Does not implicitly {@link google.datastore.admin.v1.GetIndexRequest.verify|verify} messages. + * @param message GetIndexRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IGetIndexRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetIndexRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.GetIndexRequest.verify|verify} messages. + * @param message GetIndexRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IGetIndexRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetIndexRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.GetIndexRequest; + + /** + * Decodes a GetIndexRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.GetIndexRequest; + + /** + * Verifies a GetIndexRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetIndexRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetIndexRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.GetIndexRequest; + + /** + * Creates a plain object from a GetIndexRequest message. Also converts values to other types if specified. + * @param message GetIndexRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.GetIndexRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetIndexRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetIndexRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListIndexesRequest. */ + interface IListIndexesRequest { + + /** ListIndexesRequest projectId */ + projectId?: (string|null); + + /** ListIndexesRequest filter */ + filter?: (string|null); + + /** ListIndexesRequest pageSize */ + pageSize?: (number|null); + + /** ListIndexesRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListIndexesRequest. */ + class ListIndexesRequest implements IListIndexesRequest { + + /** + * Constructs a new ListIndexesRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IListIndexesRequest); + + /** ListIndexesRequest projectId. */ + public projectId: string; + + /** ListIndexesRequest filter. */ + public filter: string; + + /** ListIndexesRequest pageSize. */ + public pageSize: number; + + /** ListIndexesRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListIndexesRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListIndexesRequest instance + */ + public static create(properties?: google.datastore.admin.v1.IListIndexesRequest): google.datastore.admin.v1.ListIndexesRequest; + + /** + * Encodes the specified ListIndexesRequest message. Does not implicitly {@link google.datastore.admin.v1.ListIndexesRequest.verify|verify} messages. + * @param message ListIndexesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IListIndexesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListIndexesRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ListIndexesRequest.verify|verify} messages. + * @param message ListIndexesRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IListIndexesRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListIndexesRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListIndexesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.ListIndexesRequest; + + /** + * Decodes a ListIndexesRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListIndexesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.ListIndexesRequest; + + /** + * Verifies a ListIndexesRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListIndexesRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListIndexesRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.ListIndexesRequest; + + /** + * Creates a plain object from a ListIndexesRequest message. Also converts values to other types if specified. + * @param message ListIndexesRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.ListIndexesRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListIndexesRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListIndexesRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListIndexesResponse. */ + interface IListIndexesResponse { + + /** ListIndexesResponse indexes */ + indexes?: (google.datastore.admin.v1.IIndex[]|null); + + /** ListIndexesResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListIndexesResponse. */ + class ListIndexesResponse implements IListIndexesResponse { + + /** + * Constructs a new ListIndexesResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IListIndexesResponse); + + /** ListIndexesResponse indexes. */ + public indexes: google.datastore.admin.v1.IIndex[]; + + /** ListIndexesResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListIndexesResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListIndexesResponse instance + */ + public static create(properties?: google.datastore.admin.v1.IListIndexesResponse): google.datastore.admin.v1.ListIndexesResponse; + + /** + * Encodes the specified ListIndexesResponse message. Does not implicitly {@link google.datastore.admin.v1.ListIndexesResponse.verify|verify} messages. + * @param message ListIndexesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IListIndexesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListIndexesResponse message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ListIndexesResponse.verify|verify} messages. + * @param message ListIndexesResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IListIndexesResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListIndexesResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListIndexesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.ListIndexesResponse; + + /** + * Decodes a ListIndexesResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListIndexesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.ListIndexesResponse; + + /** + * Verifies a ListIndexesResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListIndexesResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListIndexesResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.ListIndexesResponse; + + /** + * Creates a plain object from a ListIndexesResponse message. Also converts values to other types if specified. + * @param message ListIndexesResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.ListIndexesResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListIndexesResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListIndexesResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an IndexOperationMetadata. */ + interface IIndexOperationMetadata { + + /** IndexOperationMetadata common */ + common?: (google.datastore.admin.v1.ICommonMetadata|null); + + /** IndexOperationMetadata progressEntities */ + progressEntities?: (google.datastore.admin.v1.IProgress|null); + + /** IndexOperationMetadata indexId */ + indexId?: (string|null); + } + + /** Represents an IndexOperationMetadata. */ + class IndexOperationMetadata implements IIndexOperationMetadata { + + /** + * Constructs a new IndexOperationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IIndexOperationMetadata); + + /** IndexOperationMetadata common. */ + public common?: (google.datastore.admin.v1.ICommonMetadata|null); + + /** IndexOperationMetadata progressEntities. */ + public progressEntities?: (google.datastore.admin.v1.IProgress|null); + + /** IndexOperationMetadata indexId. */ + public indexId: string; + + /** + * Creates a new IndexOperationMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns IndexOperationMetadata instance + */ + public static create(properties?: google.datastore.admin.v1.IIndexOperationMetadata): google.datastore.admin.v1.IndexOperationMetadata; + + /** + * Encodes the specified IndexOperationMetadata message. Does not implicitly {@link google.datastore.admin.v1.IndexOperationMetadata.verify|verify} messages. + * @param message IndexOperationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IIndexOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified IndexOperationMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.IndexOperationMetadata.verify|verify} messages. + * @param message IndexOperationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IIndexOperationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an IndexOperationMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns IndexOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.IndexOperationMetadata; + + /** + * Decodes an IndexOperationMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns IndexOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.IndexOperationMetadata; + + /** + * Verifies an IndexOperationMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an IndexOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexOperationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.IndexOperationMetadata; + + /** + * Creates a plain object from an IndexOperationMetadata message. Also converts values to other types if specified. + * @param message IndexOperationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.IndexOperationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexOperationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for IndexOperationMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DatastoreFirestoreMigrationMetadata. */ + interface IDatastoreFirestoreMigrationMetadata { + + /** DatastoreFirestoreMigrationMetadata migrationState */ + migrationState?: (google.datastore.admin.v1.MigrationState|keyof typeof google.datastore.admin.v1.MigrationState|null); + + /** DatastoreFirestoreMigrationMetadata migrationStep */ + migrationStep?: (google.datastore.admin.v1.MigrationStep|keyof typeof google.datastore.admin.v1.MigrationStep|null); + } + + /** Represents a DatastoreFirestoreMigrationMetadata. */ + class DatastoreFirestoreMigrationMetadata implements IDatastoreFirestoreMigrationMetadata { + + /** + * Constructs a new DatastoreFirestoreMigrationMetadata. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata); + + /** DatastoreFirestoreMigrationMetadata migrationState. */ + public migrationState: (google.datastore.admin.v1.MigrationState|keyof typeof google.datastore.admin.v1.MigrationState); + + /** DatastoreFirestoreMigrationMetadata migrationStep. */ + public migrationStep: (google.datastore.admin.v1.MigrationStep|keyof typeof google.datastore.admin.v1.MigrationStep); + + /** + * Creates a new DatastoreFirestoreMigrationMetadata instance using the specified properties. + * @param [properties] Properties to set + * @returns DatastoreFirestoreMigrationMetadata instance + */ + public static create(properties?: google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata): google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata; + + /** + * Encodes the specified DatastoreFirestoreMigrationMetadata message. Does not implicitly {@link google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.verify|verify} messages. + * @param message DatastoreFirestoreMigrationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DatastoreFirestoreMigrationMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.verify|verify} messages. + * @param message DatastoreFirestoreMigrationMetadata message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DatastoreFirestoreMigrationMetadata message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DatastoreFirestoreMigrationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata; + + /** + * Decodes a DatastoreFirestoreMigrationMetadata message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DatastoreFirestoreMigrationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata; + + /** + * Verifies a DatastoreFirestoreMigrationMetadata message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DatastoreFirestoreMigrationMetadata message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DatastoreFirestoreMigrationMetadata + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata; + + /** + * Creates a plain object from a DatastoreFirestoreMigrationMetadata message. Also converts values to other types if specified. + * @param message DatastoreFirestoreMigrationMetadata + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DatastoreFirestoreMigrationMetadata to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DatastoreFirestoreMigrationMetadata + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** OperationType enum. */ + enum OperationType { + OPERATION_TYPE_UNSPECIFIED = 0, + EXPORT_ENTITIES = 1, + IMPORT_ENTITIES = 2, + CREATE_INDEX = 3, + DELETE_INDEX = 4 + } + + /** Properties of an Index. */ + interface IIndex { + + /** Index projectId */ + projectId?: (string|null); + + /** Index indexId */ + indexId?: (string|null); + + /** Index kind */ + kind?: (string|null); + + /** Index ancestor */ + ancestor?: (google.datastore.admin.v1.Index.AncestorMode|keyof typeof google.datastore.admin.v1.Index.AncestorMode|null); + + /** Index properties */ + properties?: (google.datastore.admin.v1.Index.IIndexedProperty[]|null); + + /** Index state */ + state?: (google.datastore.admin.v1.Index.State|keyof typeof google.datastore.admin.v1.Index.State|null); + } + + /** Represents an Index. */ + class Index implements IIndex { + + /** + * Constructs a new Index. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IIndex); + + /** Index projectId. */ + public projectId: string; + + /** Index indexId. */ + public indexId: string; + + /** Index kind. */ + public kind: string; + + /** Index ancestor. */ + public ancestor: (google.datastore.admin.v1.Index.AncestorMode|keyof typeof google.datastore.admin.v1.Index.AncestorMode); + + /** Index properties. */ + public properties: google.datastore.admin.v1.Index.IIndexedProperty[]; + + /** Index state. */ + public state: (google.datastore.admin.v1.Index.State|keyof typeof google.datastore.admin.v1.Index.State); + + /** + * Creates a new Index instance using the specified properties. + * @param [properties] Properties to set + * @returns Index instance + */ + public static create(properties?: google.datastore.admin.v1.IIndex): google.datastore.admin.v1.Index; + + /** + * Encodes the specified Index message. Does not implicitly {@link google.datastore.admin.v1.Index.verify|verify} messages. + * @param message Index message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IIndex, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Index message, length delimited. Does not implicitly {@link google.datastore.admin.v1.Index.verify|verify} messages. + * @param message Index message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IIndex, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Index message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Index + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.Index; + + /** + * Decodes an Index message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Index + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.Index; + + /** + * Verifies an Index message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Index message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Index + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.Index; + + /** + * Creates a plain object from an Index message. Also converts values to other types if specified. + * @param message Index + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.Index, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Index to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Index + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Index { + + /** AncestorMode enum. */ + enum AncestorMode { + ANCESTOR_MODE_UNSPECIFIED = 0, + NONE = 1, + ALL_ANCESTORS = 2 + } + + /** Direction enum. */ + enum Direction { + DIRECTION_UNSPECIFIED = 0, + ASCENDING = 1, + DESCENDING = 2 + } + + /** Properties of an IndexedProperty. */ + interface IIndexedProperty { + + /** IndexedProperty name */ + name?: (string|null); + + /** IndexedProperty direction */ + direction?: (google.datastore.admin.v1.Index.Direction|keyof typeof google.datastore.admin.v1.Index.Direction|null); + } + + /** Represents an IndexedProperty. */ + class IndexedProperty implements IIndexedProperty { + + /** + * Constructs a new IndexedProperty. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.Index.IIndexedProperty); + + /** IndexedProperty name. */ + public name: string; + + /** IndexedProperty direction. */ + public direction: (google.datastore.admin.v1.Index.Direction|keyof typeof google.datastore.admin.v1.Index.Direction); + + /** + * Creates a new IndexedProperty instance using the specified properties. + * @param [properties] Properties to set + * @returns IndexedProperty instance + */ + public static create(properties?: google.datastore.admin.v1.Index.IIndexedProperty): google.datastore.admin.v1.Index.IndexedProperty; + + /** + * Encodes the specified IndexedProperty message. Does not implicitly {@link google.datastore.admin.v1.Index.IndexedProperty.verify|verify} messages. + * @param message IndexedProperty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.Index.IIndexedProperty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified IndexedProperty message, length delimited. Does not implicitly {@link google.datastore.admin.v1.Index.IndexedProperty.verify|verify} messages. + * @param message IndexedProperty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.Index.IIndexedProperty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an IndexedProperty message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns IndexedProperty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.Index.IndexedProperty; + + /** + * Decodes an IndexedProperty message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns IndexedProperty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.Index.IndexedProperty; + + /** + * Verifies an IndexedProperty message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an IndexedProperty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns IndexedProperty + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.Index.IndexedProperty; + + /** + * Creates a plain object from an IndexedProperty message. Also converts values to other types if specified. + * @param message IndexedProperty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.Index.IndexedProperty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this IndexedProperty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for IndexedProperty + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + CREATING = 1, + READY = 2, + DELETING = 3, + ERROR = 4 + } + } + + /** Properties of a MigrationStateEvent. */ + interface IMigrationStateEvent { + + /** MigrationStateEvent state */ + state?: (google.datastore.admin.v1.MigrationState|keyof typeof google.datastore.admin.v1.MigrationState|null); + } + + /** Represents a MigrationStateEvent. */ + class MigrationStateEvent implements IMigrationStateEvent { + + /** + * Constructs a new MigrationStateEvent. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IMigrationStateEvent); + + /** MigrationStateEvent state. */ + public state: (google.datastore.admin.v1.MigrationState|keyof typeof google.datastore.admin.v1.MigrationState); + + /** + * Creates a new MigrationStateEvent instance using the specified properties. + * @param [properties] Properties to set + * @returns MigrationStateEvent instance + */ + public static create(properties?: google.datastore.admin.v1.IMigrationStateEvent): google.datastore.admin.v1.MigrationStateEvent; + + /** + * Encodes the specified MigrationStateEvent message. Does not implicitly {@link google.datastore.admin.v1.MigrationStateEvent.verify|verify} messages. + * @param message MigrationStateEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IMigrationStateEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MigrationStateEvent message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationStateEvent.verify|verify} messages. + * @param message MigrationStateEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IMigrationStateEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MigrationStateEvent message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MigrationStateEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.MigrationStateEvent; + + /** + * Decodes a MigrationStateEvent message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MigrationStateEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.MigrationStateEvent; + + /** + * Verifies a MigrationStateEvent message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MigrationStateEvent message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MigrationStateEvent + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.MigrationStateEvent; + + /** + * Creates a plain object from a MigrationStateEvent message. Also converts values to other types if specified. + * @param message MigrationStateEvent + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.MigrationStateEvent, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MigrationStateEvent to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MigrationStateEvent + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MigrationProgressEvent. */ + interface IMigrationProgressEvent { + + /** MigrationProgressEvent step */ + step?: (google.datastore.admin.v1.MigrationStep|keyof typeof google.datastore.admin.v1.MigrationStep|null); + + /** MigrationProgressEvent prepareStepDetails */ + prepareStepDetails?: (google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails|null); + + /** MigrationProgressEvent redirectWritesStepDetails */ + redirectWritesStepDetails?: (google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails|null); + } + + /** Represents a MigrationProgressEvent. */ + class MigrationProgressEvent implements IMigrationProgressEvent { + + /** + * Constructs a new MigrationProgressEvent. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.IMigrationProgressEvent); + + /** MigrationProgressEvent step. */ + public step: (google.datastore.admin.v1.MigrationStep|keyof typeof google.datastore.admin.v1.MigrationStep); + + /** MigrationProgressEvent prepareStepDetails. */ + public prepareStepDetails?: (google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails|null); + + /** MigrationProgressEvent redirectWritesStepDetails. */ + public redirectWritesStepDetails?: (google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails|null); + + /** MigrationProgressEvent stepDetails. */ + public stepDetails?: ("prepareStepDetails"|"redirectWritesStepDetails"); + + /** + * Creates a new MigrationProgressEvent instance using the specified properties. + * @param [properties] Properties to set + * @returns MigrationProgressEvent instance + */ + public static create(properties?: google.datastore.admin.v1.IMigrationProgressEvent): google.datastore.admin.v1.MigrationProgressEvent; + + /** + * Encodes the specified MigrationProgressEvent message. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.verify|verify} messages. + * @param message MigrationProgressEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.IMigrationProgressEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MigrationProgressEvent message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.verify|verify} messages. + * @param message MigrationProgressEvent message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.IMigrationProgressEvent, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MigrationProgressEvent message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MigrationProgressEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.MigrationProgressEvent; + + /** + * Decodes a MigrationProgressEvent message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MigrationProgressEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.MigrationProgressEvent; + + /** + * Verifies a MigrationProgressEvent message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MigrationProgressEvent message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MigrationProgressEvent + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.MigrationProgressEvent; + + /** + * Creates a plain object from a MigrationProgressEvent message. Also converts values to other types if specified. + * @param message MigrationProgressEvent + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.MigrationProgressEvent, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MigrationProgressEvent to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MigrationProgressEvent + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace MigrationProgressEvent { + + /** ConcurrencyMode enum. */ + enum ConcurrencyMode { + CONCURRENCY_MODE_UNSPECIFIED = 0, + PESSIMISTIC = 1, + OPTIMISTIC = 2, + OPTIMISTIC_WITH_ENTITY_GROUPS = 3 + } + + /** Properties of a PrepareStepDetails. */ + interface IPrepareStepDetails { + + /** PrepareStepDetails concurrencyMode */ + concurrencyMode?: (google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|keyof typeof google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|null); + } + + /** Represents a PrepareStepDetails. */ + class PrepareStepDetails implements IPrepareStepDetails { + + /** + * Constructs a new PrepareStepDetails. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails); + + /** PrepareStepDetails concurrencyMode. */ + public concurrencyMode: (google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|keyof typeof google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode); + + /** + * Creates a new PrepareStepDetails instance using the specified properties. + * @param [properties] Properties to set + * @returns PrepareStepDetails instance + */ + public static create(properties?: google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails): google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails; + + /** + * Encodes the specified PrepareStepDetails message. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.verify|verify} messages. + * @param message PrepareStepDetails message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PrepareStepDetails message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.verify|verify} messages. + * @param message PrepareStepDetails message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PrepareStepDetails message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PrepareStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails; + + /** + * Decodes a PrepareStepDetails message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PrepareStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails; + + /** + * Verifies a PrepareStepDetails message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PrepareStepDetails message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PrepareStepDetails + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails; + + /** + * Creates a plain object from a PrepareStepDetails message. Also converts values to other types if specified. + * @param message PrepareStepDetails + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PrepareStepDetails to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PrepareStepDetails + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RedirectWritesStepDetails. */ + interface IRedirectWritesStepDetails { + + /** RedirectWritesStepDetails concurrencyMode */ + concurrencyMode?: (google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|keyof typeof google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|null); + } + + /** Represents a RedirectWritesStepDetails. */ + class RedirectWritesStepDetails implements IRedirectWritesStepDetails { + + /** + * Constructs a new RedirectWritesStepDetails. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails); + + /** RedirectWritesStepDetails concurrencyMode. */ + public concurrencyMode: (google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|keyof typeof google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode); + + /** + * Creates a new RedirectWritesStepDetails instance using the specified properties. + * @param [properties] Properties to set + * @returns RedirectWritesStepDetails instance + */ + public static create(properties?: google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails): google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails; + + /** + * Encodes the specified RedirectWritesStepDetails message. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.verify|verify} messages. + * @param message RedirectWritesStepDetails message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RedirectWritesStepDetails message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.verify|verify} messages. + * @param message RedirectWritesStepDetails message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RedirectWritesStepDetails message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RedirectWritesStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails; + + /** + * Decodes a RedirectWritesStepDetails message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RedirectWritesStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails; + + /** + * Verifies a RedirectWritesStepDetails message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RedirectWritesStepDetails message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RedirectWritesStepDetails + */ + public static fromObject(object: { [k: string]: any }): google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails; + + /** + * Creates a plain object from a RedirectWritesStepDetails message. Also converts values to other types if specified. + * @param message RedirectWritesStepDetails + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RedirectWritesStepDetails to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RedirectWritesStepDetails + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** MigrationState enum. */ + enum MigrationState { + MIGRATION_STATE_UNSPECIFIED = 0, + RUNNING = 1, + PAUSED = 2, + COMPLETE = 3 + } + + /** MigrationStep enum. */ + enum MigrationStep { + MIGRATION_STEP_UNSPECIFIED = 0, + PREPARE = 6, + START = 1, + APPLY_WRITES_SYNCHRONOUSLY = 7, + COPY_AND_VERIFY = 2, + REDIRECT_EVENTUALLY_CONSISTENT_READS = 3, + REDIRECT_STRONGLY_CONSISTENT_READS = 4, + REDIRECT_WRITES = 5 + } + } + } + + /** Namespace v1. */ + namespace v1 { + + /** Properties of an AggregationResult. */ + interface IAggregationResult { + + /** AggregationResult aggregateProperties */ + aggregateProperties?: ({ [k: string]: google.datastore.v1.IValue }|null); + } + + /** Represents an AggregationResult. */ + class AggregationResult implements IAggregationResult { + + /** + * Constructs a new AggregationResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IAggregationResult); + + /** AggregationResult aggregateProperties. */ + public aggregateProperties: { [k: string]: google.datastore.v1.IValue }; + + /** + * Creates a new AggregationResult instance using the specified properties. + * @param [properties] Properties to set + * @returns AggregationResult instance + */ + public static create(properties?: google.datastore.v1.IAggregationResult): google.datastore.v1.AggregationResult; + + /** + * Encodes the specified AggregationResult message. Does not implicitly {@link google.datastore.v1.AggregationResult.verify|verify} messages. + * @param message AggregationResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IAggregationResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AggregationResult message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationResult.verify|verify} messages. + * @param message AggregationResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IAggregationResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AggregationResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AggregationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AggregationResult; + + /** + * Decodes an AggregationResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AggregationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AggregationResult; + + /** + * Verifies an AggregationResult message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AggregationResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AggregationResult + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AggregationResult; + + /** + * Creates a plain object from an AggregationResult message. Also converts values to other types if specified. + * @param message AggregationResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AggregationResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AggregationResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AggregationResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AggregationResultBatch. */ + interface IAggregationResultBatch { + + /** AggregationResultBatch aggregationResults */ + aggregationResults?: (google.datastore.v1.IAggregationResult[]|null); + + /** AggregationResultBatch moreResults */ + moreResults?: (google.datastore.v1.QueryResultBatch.MoreResultsType|keyof typeof google.datastore.v1.QueryResultBatch.MoreResultsType|null); + + /** AggregationResultBatch readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents an AggregationResultBatch. */ + class AggregationResultBatch implements IAggregationResultBatch { + + /** + * Constructs a new AggregationResultBatch. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IAggregationResultBatch); + + /** AggregationResultBatch aggregationResults. */ + public aggregationResults: google.datastore.v1.IAggregationResult[]; + + /** AggregationResultBatch moreResults. */ + public moreResults: (google.datastore.v1.QueryResultBatch.MoreResultsType|keyof typeof google.datastore.v1.QueryResultBatch.MoreResultsType); + + /** AggregationResultBatch readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new AggregationResultBatch instance using the specified properties. + * @param [properties] Properties to set + * @returns AggregationResultBatch instance + */ + public static create(properties?: google.datastore.v1.IAggregationResultBatch): google.datastore.v1.AggregationResultBatch; + + /** + * Encodes the specified AggregationResultBatch message. Does not implicitly {@link google.datastore.v1.AggregationResultBatch.verify|verify} messages. + * @param message AggregationResultBatch message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IAggregationResultBatch, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AggregationResultBatch message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationResultBatch.verify|verify} messages. + * @param message AggregationResultBatch message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IAggregationResultBatch, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AggregationResultBatch message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AggregationResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AggregationResultBatch; + + /** + * Decodes an AggregationResultBatch message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AggregationResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AggregationResultBatch; + + /** + * Verifies an AggregationResultBatch message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AggregationResultBatch message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AggregationResultBatch + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AggregationResultBatch; + + /** + * Creates a plain object from an AggregationResultBatch message. Also converts values to other types if specified. + * @param message AggregationResultBatch + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AggregationResultBatch, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AggregationResultBatch to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AggregationResultBatch + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PartitionId. */ + interface IPartitionId { + + /** PartitionId projectId */ + projectId?: (string|null); + + /** PartitionId databaseId */ + databaseId?: (string|null); + + /** PartitionId namespaceId */ + namespaceId?: (string|null); + } + + /** Represents a PartitionId. */ + class PartitionId implements IPartitionId { + + /** + * Constructs a new PartitionId. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IPartitionId); + + /** PartitionId projectId. */ + public projectId: string; + + /** PartitionId databaseId. */ + public databaseId: string; + + /** PartitionId namespaceId. */ + public namespaceId: string; + + /** + * Creates a new PartitionId instance using the specified properties. + * @param [properties] Properties to set + * @returns PartitionId instance + */ + public static create(properties?: google.datastore.v1.IPartitionId): google.datastore.v1.PartitionId; + + /** + * Encodes the specified PartitionId message. Does not implicitly {@link google.datastore.v1.PartitionId.verify|verify} messages. + * @param message PartitionId message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IPartitionId, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PartitionId message, length delimited. Does not implicitly {@link google.datastore.v1.PartitionId.verify|verify} messages. + * @param message PartitionId message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IPartitionId, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PartitionId message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PartitionId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.PartitionId; + + /** + * Decodes a PartitionId message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PartitionId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.PartitionId; + + /** + * Verifies a PartitionId message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PartitionId message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PartitionId + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.PartitionId; + + /** + * Creates a plain object from a PartitionId message. Also converts values to other types if specified. + * @param message PartitionId + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.PartitionId, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PartitionId to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PartitionId + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Key. */ + interface IKey { + + /** Key partitionId */ + partitionId?: (google.datastore.v1.IPartitionId|null); + + /** Key path */ + path?: (google.datastore.v1.Key.IPathElement[]|null); + } + + /** Represents a Key. */ + class Key implements IKey { + + /** + * Constructs a new Key. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IKey); + + /** Key partitionId. */ + public partitionId?: (google.datastore.v1.IPartitionId|null); + + /** Key path. */ + public path: google.datastore.v1.Key.IPathElement[]; + + /** + * Creates a new Key instance using the specified properties. + * @param [properties] Properties to set + * @returns Key instance + */ + public static create(properties?: google.datastore.v1.IKey): google.datastore.v1.Key; + + /** + * Encodes the specified Key message. Does not implicitly {@link google.datastore.v1.Key.verify|verify} messages. + * @param message Key message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Key message, length delimited. Does not implicitly {@link google.datastore.v1.Key.verify|verify} messages. + * @param message Key message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Key message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Key + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Key; + + /** + * Decodes a Key message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Key + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Key; + + /** + * Verifies a Key message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Key message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Key + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Key; + + /** + * Creates a plain object from a Key message. Also converts values to other types if specified. + * @param message Key + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Key, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Key to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Key + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Key { + + /** Properties of a PathElement. */ + interface IPathElement { + + /** PathElement kind */ + kind?: (string|null); + + /** PathElement id */ + id?: (number|Long|string|null); + + /** PathElement name */ + name?: (string|null); + } + + /** Represents a PathElement. */ + class PathElement implements IPathElement { + + /** + * Constructs a new PathElement. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.Key.IPathElement); + + /** PathElement kind. */ + public kind: string; + + /** PathElement id. */ + public id?: (number|Long|string|null); + + /** PathElement name. */ + public name?: (string|null); + + /** PathElement idType. */ + public idType?: ("id"|"name"); + + /** + * Creates a new PathElement instance using the specified properties. + * @param [properties] Properties to set + * @returns PathElement instance + */ + public static create(properties?: google.datastore.v1.Key.IPathElement): google.datastore.v1.Key.PathElement; + + /** + * Encodes the specified PathElement message. Does not implicitly {@link google.datastore.v1.Key.PathElement.verify|verify} messages. + * @param message PathElement message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.Key.IPathElement, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PathElement message, length delimited. Does not implicitly {@link google.datastore.v1.Key.PathElement.verify|verify} messages. + * @param message PathElement message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.Key.IPathElement, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PathElement message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PathElement + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Key.PathElement; + + /** + * Decodes a PathElement message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PathElement + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Key.PathElement; + + /** + * Verifies a PathElement message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PathElement message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PathElement + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Key.PathElement; + + /** + * Creates a plain object from a PathElement message. Also converts values to other types if specified. + * @param message PathElement + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Key.PathElement, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PathElement to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PathElement + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an ArrayValue. */ + interface IArrayValue { + + /** ArrayValue values */ + values?: (google.datastore.v1.IValue[]|null); + } + + /** Represents an ArrayValue. */ + class ArrayValue implements IArrayValue { + + /** + * Constructs a new ArrayValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IArrayValue); + + /** ArrayValue values. */ + public values: google.datastore.v1.IValue[]; + + /** + * Creates a new ArrayValue instance using the specified properties. + * @param [properties] Properties to set + * @returns ArrayValue instance + */ + public static create(properties?: google.datastore.v1.IArrayValue): google.datastore.v1.ArrayValue; + + /** + * Encodes the specified ArrayValue message. Does not implicitly {@link google.datastore.v1.ArrayValue.verify|verify} messages. + * @param message ArrayValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IArrayValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ArrayValue message, length delimited. Does not implicitly {@link google.datastore.v1.ArrayValue.verify|verify} messages. + * @param message ArrayValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IArrayValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ArrayValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.ArrayValue; + + /** + * Decodes an ArrayValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.ArrayValue; + + /** + * Verifies an ArrayValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ArrayValue + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.ArrayValue; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @param message ArrayValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.ArrayValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ArrayValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ArrayValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|keyof typeof google.protobuf.NullValue|null); + + /** Value booleanValue */ + booleanValue?: (boolean|null); + + /** Value integerValue */ + integerValue?: (number|Long|string|null); + + /** Value doubleValue */ + doubleValue?: (number|null); + + /** Value timestampValue */ + timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value keyValue */ + keyValue?: (google.datastore.v1.IKey|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value blobValue */ + blobValue?: (Uint8Array|Buffer|string|null); + + /** Value geoPointValue */ + geoPointValue?: (google.type.ILatLng|null); + + /** Value entityValue */ + entityValue?: (google.datastore.v1.IEntity|null); + + /** Value arrayValue */ + arrayValue?: (google.datastore.v1.IArrayValue|null); + + /** Value meaning */ + meaning?: (number|null); + + /** Value excludeFromIndexes */ + excludeFromIndexes?: (boolean|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IValue); + + /** Value nullValue. */ + public nullValue?: (google.protobuf.NullValue|keyof typeof google.protobuf.NullValue|null); + + /** Value booleanValue. */ + public booleanValue?: (boolean|null); + + /** Value integerValue. */ + public integerValue?: (number|Long|string|null); + + /** Value doubleValue. */ + public doubleValue?: (number|null); + + /** Value timestampValue. */ + public timestampValue?: (google.protobuf.ITimestamp|null); + + /** Value keyValue. */ + public keyValue?: (google.datastore.v1.IKey|null); + + /** Value stringValue. */ + public stringValue?: (string|null); + + /** Value blobValue. */ + public blobValue?: (Uint8Array|Buffer|string|null); + + /** Value geoPointValue. */ + public geoPointValue?: (google.type.ILatLng|null); + + /** Value entityValue. */ + public entityValue?: (google.datastore.v1.IEntity|null); + + /** Value arrayValue. */ + public arrayValue?: (google.datastore.v1.IArrayValue|null); + + /** Value meaning. */ + public meaning: number; + + /** Value excludeFromIndexes. */ + public excludeFromIndexes: boolean; + + /** Value valueType. */ + public valueType?: ("nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"keyValue"|"stringValue"|"blobValue"|"geoPointValue"|"entityValue"|"arrayValue"); + + /** + * Creates a new Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Value instance + */ + public static create(properties?: google.datastore.v1.IValue): google.datastore.v1.Value; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.datastore.v1.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.datastore.v1.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Value; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Value; + + /** + * Verifies a Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Entity. */ + interface IEntity { + + /** Entity key */ + key?: (google.datastore.v1.IKey|null); + + /** Entity properties */ + properties?: ({ [k: string]: google.datastore.v1.IValue }|null); + } + + /** Represents an Entity. */ + class Entity implements IEntity { + + /** + * Constructs a new Entity. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IEntity); + + /** Entity key. */ + public key?: (google.datastore.v1.IKey|null); + + /** Entity properties. */ + public properties: { [k: string]: google.datastore.v1.IValue }; + + /** + * Creates a new Entity instance using the specified properties. + * @param [properties] Properties to set + * @returns Entity instance + */ + public static create(properties?: google.datastore.v1.IEntity): google.datastore.v1.Entity; + + /** + * Encodes the specified Entity message. Does not implicitly {@link google.datastore.v1.Entity.verify|verify} messages. + * @param message Entity message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IEntity, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Entity message, length delimited. Does not implicitly {@link google.datastore.v1.Entity.verify|verify} messages. + * @param message Entity message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IEntity, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Entity message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Entity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Entity; + + /** + * Decodes an Entity message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Entity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Entity; + + /** + * Verifies an Entity message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Entity message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Entity + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Entity; + + /** + * Creates a plain object from an Entity message. Also converts values to other types if specified. + * @param message Entity + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Entity, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Entity to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Entity + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an EntityResult. */ + interface IEntityResult { + + /** EntityResult entity */ + entity?: (google.datastore.v1.IEntity|null); + + /** EntityResult version */ + version?: (number|Long|string|null); + + /** EntityResult createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** EntityResult updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** EntityResult cursor */ + cursor?: (Uint8Array|Buffer|string|null); + } + + /** Represents an EntityResult. */ + class EntityResult implements IEntityResult { + + /** + * Constructs a new EntityResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IEntityResult); + + /** EntityResult entity. */ + public entity?: (google.datastore.v1.IEntity|null); + + /** EntityResult version. */ + public version: (number|Long|string); + + /** EntityResult createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** EntityResult updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** EntityResult cursor. */ + public cursor: (Uint8Array|Buffer|string); + + /** + * Creates a new EntityResult instance using the specified properties. + * @param [properties] Properties to set + * @returns EntityResult instance + */ + public static create(properties?: google.datastore.v1.IEntityResult): google.datastore.v1.EntityResult; + + /** + * Encodes the specified EntityResult message. Does not implicitly {@link google.datastore.v1.EntityResult.verify|verify} messages. + * @param message EntityResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IEntityResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EntityResult message, length delimited. Does not implicitly {@link google.datastore.v1.EntityResult.verify|verify} messages. + * @param message EntityResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IEntityResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EntityResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EntityResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.EntityResult; + + /** + * Decodes an EntityResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EntityResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.EntityResult; + + /** + * Verifies an EntityResult message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EntityResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EntityResult + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.EntityResult; + + /** + * Creates a plain object from an EntityResult message. Also converts values to other types if specified. + * @param message EntityResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.EntityResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EntityResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EntityResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace EntityResult { + + /** ResultType enum. */ + enum ResultType { + RESULT_TYPE_UNSPECIFIED = 0, + FULL = 1, + PROJECTION = 2, + KEY_ONLY = 3 + } + } + + /** Properties of a Query. */ + interface IQuery { + + /** Query projection */ + projection?: (google.datastore.v1.IProjection[]|null); + + /** Query kind */ + kind?: (google.datastore.v1.IKindExpression[]|null); + + /** Query filter */ + filter?: (google.datastore.v1.IFilter|null); + + /** Query order */ + order?: (google.datastore.v1.IPropertyOrder[]|null); + + /** Query distinctOn */ + distinctOn?: (google.datastore.v1.IPropertyReference[]|null); + + /** Query startCursor */ + startCursor?: (Uint8Array|Buffer|string|null); + + /** Query endCursor */ + endCursor?: (Uint8Array|Buffer|string|null); + + /** Query offset */ + offset?: (number|null); + + /** Query limit */ + limit?: (google.protobuf.IInt32Value|null); + + /** Query findNearest */ + findNearest?: (google.datastore.v1.IFindNearest|null); + } + + /** Represents a Query. */ + class Query implements IQuery { + + /** + * Constructs a new Query. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IQuery); + + /** Query projection. */ + public projection: google.datastore.v1.IProjection[]; + + /** Query kind. */ + public kind: google.datastore.v1.IKindExpression[]; + + /** Query filter. */ + public filter?: (google.datastore.v1.IFilter|null); + + /** Query order. */ + public order: google.datastore.v1.IPropertyOrder[]; + + /** Query distinctOn. */ + public distinctOn: google.datastore.v1.IPropertyReference[]; + + /** Query startCursor. */ + public startCursor: (Uint8Array|Buffer|string); + + /** Query endCursor. */ + public endCursor: (Uint8Array|Buffer|string); + + /** Query offset. */ + public offset: number; + + /** Query limit. */ + public limit?: (google.protobuf.IInt32Value|null); + + /** Query findNearest. */ + public findNearest?: (google.datastore.v1.IFindNearest|null); + + /** + * Creates a new Query instance using the specified properties. + * @param [properties] Properties to set + * @returns Query instance + */ + public static create(properties?: google.datastore.v1.IQuery): google.datastore.v1.Query; + + /** + * Encodes the specified Query message. Does not implicitly {@link google.datastore.v1.Query.verify|verify} messages. + * @param message Query message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Query message, length delimited. Does not implicitly {@link google.datastore.v1.Query.verify|verify} messages. + * @param message Query message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Query message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Query + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Query; + + /** + * Decodes a Query message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Query + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Query; + + /** + * Verifies a Query message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Query message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Query + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Query; + + /** + * Creates a plain object from a Query message. Also converts values to other types if specified. + * @param message Query + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Query, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Query to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Query + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AggregationQuery. */ + interface IAggregationQuery { + + /** AggregationQuery nestedQuery */ + nestedQuery?: (google.datastore.v1.IQuery|null); + + /** AggregationQuery aggregations */ + aggregations?: (google.datastore.v1.AggregationQuery.IAggregation[]|null); + } + + /** Represents an AggregationQuery. */ + class AggregationQuery implements IAggregationQuery { + + /** + * Constructs a new AggregationQuery. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IAggregationQuery); + + /** AggregationQuery nestedQuery. */ + public nestedQuery?: (google.datastore.v1.IQuery|null); + + /** AggregationQuery aggregations. */ + public aggregations: google.datastore.v1.AggregationQuery.IAggregation[]; + + /** AggregationQuery queryType. */ + public queryType?: "nestedQuery"; + + /** + * Creates a new AggregationQuery instance using the specified properties. + * @param [properties] Properties to set + * @returns AggregationQuery instance + */ + public static create(properties?: google.datastore.v1.IAggregationQuery): google.datastore.v1.AggregationQuery; + + /** + * Encodes the specified AggregationQuery message. Does not implicitly {@link google.datastore.v1.AggregationQuery.verify|verify} messages. + * @param message AggregationQuery message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IAggregationQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AggregationQuery message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.verify|verify} messages. + * @param message AggregationQuery message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IAggregationQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AggregationQuery message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AggregationQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AggregationQuery; + + /** + * Decodes an AggregationQuery message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AggregationQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AggregationQuery; + + /** + * Verifies an AggregationQuery message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AggregationQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AggregationQuery + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AggregationQuery; + + /** + * Creates a plain object from an AggregationQuery message. Also converts values to other types if specified. + * @param message AggregationQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AggregationQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AggregationQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AggregationQuery + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace AggregationQuery { + + /** Properties of an Aggregation. */ + interface IAggregation { + + /** Aggregation count */ + count?: (google.datastore.v1.AggregationQuery.Aggregation.ICount|null); + + /** Aggregation sum */ + sum?: (google.datastore.v1.AggregationQuery.Aggregation.ISum|null); + + /** Aggregation avg */ + avg?: (google.datastore.v1.AggregationQuery.Aggregation.IAvg|null); + + /** Aggregation alias */ + alias?: (string|null); + } + + /** Represents an Aggregation. */ + class Aggregation implements IAggregation { + + /** + * Constructs a new Aggregation. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.AggregationQuery.IAggregation); + + /** Aggregation count. */ + public count?: (google.datastore.v1.AggregationQuery.Aggregation.ICount|null); + + /** Aggregation sum. */ + public sum?: (google.datastore.v1.AggregationQuery.Aggregation.ISum|null); + + /** Aggregation avg. */ + public avg?: (google.datastore.v1.AggregationQuery.Aggregation.IAvg|null); + + /** Aggregation alias. */ + public alias: string; + + /** Aggregation operator. */ + public operator?: ("count"|"sum"|"avg"); + + /** + * Creates a new Aggregation instance using the specified properties. + * @param [properties] Properties to set + * @returns Aggregation instance + */ + public static create(properties?: google.datastore.v1.AggregationQuery.IAggregation): google.datastore.v1.AggregationQuery.Aggregation; + + /** + * Encodes the specified Aggregation message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.verify|verify} messages. + * @param message Aggregation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.AggregationQuery.IAggregation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Aggregation message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.verify|verify} messages. + * @param message Aggregation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.AggregationQuery.IAggregation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Aggregation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Aggregation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AggregationQuery.Aggregation; + + /** + * Decodes an Aggregation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Aggregation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AggregationQuery.Aggregation; + + /** + * Verifies an Aggregation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Aggregation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Aggregation + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AggregationQuery.Aggregation; + + /** + * Creates a plain object from an Aggregation message. Also converts values to other types if specified. + * @param message Aggregation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AggregationQuery.Aggregation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Aggregation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Aggregation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Aggregation { + + /** Properties of a Count. */ + interface ICount { + + /** Count upTo */ + upTo?: (google.protobuf.IInt64Value|null); + } + + /** Represents a Count. */ + class Count implements ICount { + + /** + * Constructs a new Count. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.AggregationQuery.Aggregation.ICount); + + /** Count upTo. */ + public upTo?: (google.protobuf.IInt64Value|null); + + /** + * Creates a new Count instance using the specified properties. + * @param [properties] Properties to set + * @returns Count instance + */ + public static create(properties?: google.datastore.v1.AggregationQuery.Aggregation.ICount): google.datastore.v1.AggregationQuery.Aggregation.Count; + + /** + * Encodes the specified Count message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Count.verify|verify} messages. + * @param message Count message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.AggregationQuery.Aggregation.ICount, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Count message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Count.verify|verify} messages. + * @param message Count message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.AggregationQuery.Aggregation.ICount, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Count message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Count + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AggregationQuery.Aggregation.Count; + + /** + * Decodes a Count message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Count + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AggregationQuery.Aggregation.Count; + + /** + * Verifies a Count message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Count message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Count + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AggregationQuery.Aggregation.Count; + + /** + * Creates a plain object from a Count message. Also converts values to other types if specified. + * @param message Count + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AggregationQuery.Aggregation.Count, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Count to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Count + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Sum. */ + interface ISum { + + /** Sum property */ + property?: (google.datastore.v1.IPropertyReference|null); + } + + /** Represents a Sum. */ + class Sum implements ISum { + + /** + * Constructs a new Sum. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.AggregationQuery.Aggregation.ISum); + + /** Sum property. */ + public property?: (google.datastore.v1.IPropertyReference|null); + + /** + * Creates a new Sum instance using the specified properties. + * @param [properties] Properties to set + * @returns Sum instance + */ + public static create(properties?: google.datastore.v1.AggregationQuery.Aggregation.ISum): google.datastore.v1.AggregationQuery.Aggregation.Sum; + + /** + * Encodes the specified Sum message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Sum.verify|verify} messages. + * @param message Sum message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.AggregationQuery.Aggregation.ISum, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Sum message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Sum.verify|verify} messages. + * @param message Sum message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.AggregationQuery.Aggregation.ISum, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Sum message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Sum + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AggregationQuery.Aggregation.Sum; + + /** + * Decodes a Sum message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Sum + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AggregationQuery.Aggregation.Sum; + + /** + * Verifies a Sum message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Sum message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Sum + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AggregationQuery.Aggregation.Sum; + + /** + * Creates a plain object from a Sum message. Also converts values to other types if specified. + * @param message Sum + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AggregationQuery.Aggregation.Sum, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Sum to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Sum + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Avg. */ + interface IAvg { + + /** Avg property */ + property?: (google.datastore.v1.IPropertyReference|null); + } + + /** Represents an Avg. */ + class Avg implements IAvg { + + /** + * Constructs a new Avg. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.AggregationQuery.Aggregation.IAvg); + + /** Avg property. */ + public property?: (google.datastore.v1.IPropertyReference|null); + + /** + * Creates a new Avg instance using the specified properties. + * @param [properties] Properties to set + * @returns Avg instance + */ + public static create(properties?: google.datastore.v1.AggregationQuery.Aggregation.IAvg): google.datastore.v1.AggregationQuery.Aggregation.Avg; + + /** + * Encodes the specified Avg message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Avg.verify|verify} messages. + * @param message Avg message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.AggregationQuery.Aggregation.IAvg, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Avg message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Avg.verify|verify} messages. + * @param message Avg message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.AggregationQuery.Aggregation.IAvg, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Avg message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Avg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AggregationQuery.Aggregation.Avg; + + /** + * Decodes an Avg message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Avg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AggregationQuery.Aggregation.Avg; + + /** + * Verifies an Avg message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Avg message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Avg + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AggregationQuery.Aggregation.Avg; + + /** + * Creates a plain object from an Avg message. Also converts values to other types if specified. + * @param message Avg + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AggregationQuery.Aggregation.Avg, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Avg to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Avg + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + } + + /** Properties of a KindExpression. */ + interface IKindExpression { + + /** KindExpression name */ + name?: (string|null); + } + + /** Represents a KindExpression. */ + class KindExpression implements IKindExpression { + + /** + * Constructs a new KindExpression. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IKindExpression); + + /** KindExpression name. */ + public name: string; + + /** + * Creates a new KindExpression instance using the specified properties. + * @param [properties] Properties to set + * @returns KindExpression instance + */ + public static create(properties?: google.datastore.v1.IKindExpression): google.datastore.v1.KindExpression; + + /** + * Encodes the specified KindExpression message. Does not implicitly {@link google.datastore.v1.KindExpression.verify|verify} messages. + * @param message KindExpression message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IKindExpression, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified KindExpression message, length delimited. Does not implicitly {@link google.datastore.v1.KindExpression.verify|verify} messages. + * @param message KindExpression message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IKindExpression, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a KindExpression message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns KindExpression + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.KindExpression; + + /** + * Decodes a KindExpression message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns KindExpression + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.KindExpression; + + /** + * Verifies a KindExpression message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a KindExpression message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns KindExpression + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.KindExpression; + + /** + * Creates a plain object from a KindExpression message. Also converts values to other types if specified. + * @param message KindExpression + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.KindExpression, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this KindExpression to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for KindExpression + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PropertyReference. */ + interface IPropertyReference { + + /** PropertyReference name */ + name?: (string|null); + } + + /** Represents a PropertyReference. */ + class PropertyReference implements IPropertyReference { + + /** + * Constructs a new PropertyReference. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IPropertyReference); + + /** PropertyReference name. */ + public name: string; + + /** + * Creates a new PropertyReference instance using the specified properties. + * @param [properties] Properties to set + * @returns PropertyReference instance + */ + public static create(properties?: google.datastore.v1.IPropertyReference): google.datastore.v1.PropertyReference; + + /** + * Encodes the specified PropertyReference message. Does not implicitly {@link google.datastore.v1.PropertyReference.verify|verify} messages. + * @param message PropertyReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IPropertyReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PropertyReference message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyReference.verify|verify} messages. + * @param message PropertyReference message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IPropertyReference, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PropertyReference message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PropertyReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.PropertyReference; + + /** + * Decodes a PropertyReference message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PropertyReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.PropertyReference; + + /** + * Verifies a PropertyReference message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PropertyReference message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PropertyReference + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.PropertyReference; + + /** + * Creates a plain object from a PropertyReference message. Also converts values to other types if specified. + * @param message PropertyReference + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.PropertyReference, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PropertyReference to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PropertyReference + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Projection. */ + interface IProjection { + + /** Projection property */ + property?: (google.datastore.v1.IPropertyReference|null); + } + + /** Represents a Projection. */ + class Projection implements IProjection { + + /** + * Constructs a new Projection. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IProjection); + + /** Projection property. */ + public property?: (google.datastore.v1.IPropertyReference|null); + + /** + * Creates a new Projection instance using the specified properties. + * @param [properties] Properties to set + * @returns Projection instance + */ + public static create(properties?: google.datastore.v1.IProjection): google.datastore.v1.Projection; + + /** + * Encodes the specified Projection message. Does not implicitly {@link google.datastore.v1.Projection.verify|verify} messages. + * @param message Projection message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IProjection, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Projection message, length delimited. Does not implicitly {@link google.datastore.v1.Projection.verify|verify} messages. + * @param message Projection message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IProjection, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Projection message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Projection; + + /** + * Decodes a Projection message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Projection; + + /** + * Verifies a Projection message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Projection + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Projection; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @param message Projection + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Projection, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Projection to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Projection + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PropertyOrder. */ + interface IPropertyOrder { + + /** PropertyOrder property */ + property?: (google.datastore.v1.IPropertyReference|null); + + /** PropertyOrder direction */ + direction?: (google.datastore.v1.PropertyOrder.Direction|keyof typeof google.datastore.v1.PropertyOrder.Direction|null); + } + + /** Represents a PropertyOrder. */ + class PropertyOrder implements IPropertyOrder { + + /** + * Constructs a new PropertyOrder. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IPropertyOrder); + + /** PropertyOrder property. */ + public property?: (google.datastore.v1.IPropertyReference|null); + + /** PropertyOrder direction. */ + public direction: (google.datastore.v1.PropertyOrder.Direction|keyof typeof google.datastore.v1.PropertyOrder.Direction); + + /** + * Creates a new PropertyOrder instance using the specified properties. + * @param [properties] Properties to set + * @returns PropertyOrder instance + */ + public static create(properties?: google.datastore.v1.IPropertyOrder): google.datastore.v1.PropertyOrder; + + /** + * Encodes the specified PropertyOrder message. Does not implicitly {@link google.datastore.v1.PropertyOrder.verify|verify} messages. + * @param message PropertyOrder message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IPropertyOrder, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PropertyOrder message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyOrder.verify|verify} messages. + * @param message PropertyOrder message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IPropertyOrder, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PropertyOrder message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PropertyOrder + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.PropertyOrder; + + /** + * Decodes a PropertyOrder message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PropertyOrder + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.PropertyOrder; + + /** + * Verifies a PropertyOrder message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PropertyOrder message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PropertyOrder + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.PropertyOrder; + + /** + * Creates a plain object from a PropertyOrder message. Also converts values to other types if specified. + * @param message PropertyOrder + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.PropertyOrder, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PropertyOrder to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PropertyOrder + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PropertyOrder { + + /** Direction enum. */ + enum Direction { + DIRECTION_UNSPECIFIED = 0, + ASCENDING = 1, + DESCENDING = 2 + } + } + + /** Properties of a Filter. */ + interface IFilter { + + /** Filter compositeFilter */ + compositeFilter?: (google.datastore.v1.ICompositeFilter|null); + + /** Filter propertyFilter */ + propertyFilter?: (google.datastore.v1.IPropertyFilter|null); + } + + /** Represents a Filter. */ + class Filter implements IFilter { + + /** + * Constructs a new Filter. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IFilter); + + /** Filter compositeFilter. */ + public compositeFilter?: (google.datastore.v1.ICompositeFilter|null); + + /** Filter propertyFilter. */ + public propertyFilter?: (google.datastore.v1.IPropertyFilter|null); + + /** Filter filterType. */ + public filterType?: ("compositeFilter"|"propertyFilter"); + + /** + * Creates a new Filter instance using the specified properties. + * @param [properties] Properties to set + * @returns Filter instance + */ + public static create(properties?: google.datastore.v1.IFilter): google.datastore.v1.Filter; + + /** + * Encodes the specified Filter message. Does not implicitly {@link google.datastore.v1.Filter.verify|verify} messages. + * @param message Filter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Filter message, length delimited. Does not implicitly {@link google.datastore.v1.Filter.verify|verify} messages. + * @param message Filter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Filter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Filter; + + /** + * Decodes a Filter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Filter; + + /** + * Verifies a Filter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Filter + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Filter; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @param message Filter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Filter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Filter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Filter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CompositeFilter. */ + interface ICompositeFilter { + + /** CompositeFilter op */ + op?: (google.datastore.v1.CompositeFilter.Operator|keyof typeof google.datastore.v1.CompositeFilter.Operator|null); + + /** CompositeFilter filters */ + filters?: (google.datastore.v1.IFilter[]|null); + } + + /** Represents a CompositeFilter. */ + class CompositeFilter implements ICompositeFilter { + + /** + * Constructs a new CompositeFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.ICompositeFilter); + + /** CompositeFilter op. */ + public op: (google.datastore.v1.CompositeFilter.Operator|keyof typeof google.datastore.v1.CompositeFilter.Operator); + + /** CompositeFilter filters. */ + public filters: google.datastore.v1.IFilter[]; + + /** + * Creates a new CompositeFilter instance using the specified properties. + * @param [properties] Properties to set + * @returns CompositeFilter instance + */ + public static create(properties?: google.datastore.v1.ICompositeFilter): google.datastore.v1.CompositeFilter; + + /** + * Encodes the specified CompositeFilter message. Does not implicitly {@link google.datastore.v1.CompositeFilter.verify|verify} messages. + * @param message CompositeFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.ICompositeFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CompositeFilter message, length delimited. Does not implicitly {@link google.datastore.v1.CompositeFilter.verify|verify} messages. + * @param message CompositeFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.ICompositeFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.CompositeFilter; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.CompositeFilter; + + /** + * Verifies a CompositeFilter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CompositeFilter + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.CompositeFilter; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @param message CompositeFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.CompositeFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CompositeFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CompositeFilter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CompositeFilter { + + /** Operator enum. */ + enum Operator { + OPERATOR_UNSPECIFIED = 0, + AND = 1, + OR = 2 + } + } + + /** Properties of a PropertyFilter. */ + interface IPropertyFilter { + + /** PropertyFilter property */ + property?: (google.datastore.v1.IPropertyReference|null); + + /** PropertyFilter op */ + op?: (google.datastore.v1.PropertyFilter.Operator|keyof typeof google.datastore.v1.PropertyFilter.Operator|null); + + /** PropertyFilter value */ + value?: (google.datastore.v1.IValue|null); + } + + /** Represents a PropertyFilter. */ + class PropertyFilter implements IPropertyFilter { + + /** + * Constructs a new PropertyFilter. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IPropertyFilter); + + /** PropertyFilter property. */ + public property?: (google.datastore.v1.IPropertyReference|null); + + /** PropertyFilter op. */ + public op: (google.datastore.v1.PropertyFilter.Operator|keyof typeof google.datastore.v1.PropertyFilter.Operator); + + /** PropertyFilter value. */ + public value?: (google.datastore.v1.IValue|null); + + /** + * Creates a new PropertyFilter instance using the specified properties. + * @param [properties] Properties to set + * @returns PropertyFilter instance + */ + public static create(properties?: google.datastore.v1.IPropertyFilter): google.datastore.v1.PropertyFilter; + + /** + * Encodes the specified PropertyFilter message. Does not implicitly {@link google.datastore.v1.PropertyFilter.verify|verify} messages. + * @param message PropertyFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IPropertyFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PropertyFilter message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyFilter.verify|verify} messages. + * @param message PropertyFilter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IPropertyFilter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PropertyFilter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PropertyFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.PropertyFilter; + + /** + * Decodes a PropertyFilter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PropertyFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.PropertyFilter; + + /** + * Verifies a PropertyFilter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PropertyFilter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PropertyFilter + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.PropertyFilter; + + /** + * Creates a plain object from a PropertyFilter message. Also converts values to other types if specified. + * @param message PropertyFilter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.PropertyFilter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PropertyFilter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PropertyFilter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PropertyFilter { + + /** Operator enum. */ + enum Operator { + OPERATOR_UNSPECIFIED = 0, + LESS_THAN = 1, + LESS_THAN_OR_EQUAL = 2, + GREATER_THAN = 3, + GREATER_THAN_OR_EQUAL = 4, + EQUAL = 5, + IN = 6, + NOT_EQUAL = 9, + HAS_ANCESTOR = 11, + NOT_IN = 13 + } + } + + /** Properties of a FindNearest. */ + interface IFindNearest { + + /** FindNearest vectorProperty */ + vectorProperty?: (google.datastore.v1.IPropertyReference|null); + + /** FindNearest queryVector */ + queryVector?: (google.datastore.v1.IValue|null); + + /** FindNearest distanceMeasure */ + distanceMeasure?: (google.datastore.v1.FindNearest.DistanceMeasure|keyof typeof google.datastore.v1.FindNearest.DistanceMeasure|null); + + /** FindNearest limit */ + limit?: (google.protobuf.IInt32Value|null); + + /** FindNearest distanceResultProperty */ + distanceResultProperty?: (string|null); + + /** FindNearest distanceThreshold */ + distanceThreshold?: (google.protobuf.IDoubleValue|null); + } + + /** Represents a FindNearest. */ + class FindNearest implements IFindNearest { + + /** + * Constructs a new FindNearest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IFindNearest); + + /** FindNearest vectorProperty. */ + public vectorProperty?: (google.datastore.v1.IPropertyReference|null); + + /** FindNearest queryVector. */ + public queryVector?: (google.datastore.v1.IValue|null); + + /** FindNearest distanceMeasure. */ + public distanceMeasure: (google.datastore.v1.FindNearest.DistanceMeasure|keyof typeof google.datastore.v1.FindNearest.DistanceMeasure); + + /** FindNearest limit. */ + public limit?: (google.protobuf.IInt32Value|null); + + /** FindNearest distanceResultProperty. */ + public distanceResultProperty: string; + + /** FindNearest distanceThreshold. */ + public distanceThreshold?: (google.protobuf.IDoubleValue|null); + + /** + * Creates a new FindNearest instance using the specified properties. + * @param [properties] Properties to set + * @returns FindNearest instance + */ + public static create(properties?: google.datastore.v1.IFindNearest): google.datastore.v1.FindNearest; + + /** + * Encodes the specified FindNearest message. Does not implicitly {@link google.datastore.v1.FindNearest.verify|verify} messages. + * @param message FindNearest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IFindNearest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FindNearest message, length delimited. Does not implicitly {@link google.datastore.v1.FindNearest.verify|verify} messages. + * @param message FindNearest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IFindNearest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FindNearest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FindNearest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.FindNearest; + + /** + * Decodes a FindNearest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FindNearest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.FindNearest; + + /** + * Verifies a FindNearest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FindNearest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FindNearest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.FindNearest; + + /** + * Creates a plain object from a FindNearest message. Also converts values to other types if specified. + * @param message FindNearest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.FindNearest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FindNearest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FindNearest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FindNearest { + + /** DistanceMeasure enum. */ + enum DistanceMeasure { + DISTANCE_MEASURE_UNSPECIFIED = 0, + EUCLIDEAN = 1, + COSINE = 2, + DOT_PRODUCT = 3 + } + } + + /** Properties of a GqlQuery. */ + interface IGqlQuery { + + /** GqlQuery queryString */ + queryString?: (string|null); + + /** GqlQuery allowLiterals */ + allowLiterals?: (boolean|null); + + /** GqlQuery namedBindings */ + namedBindings?: ({ [k: string]: google.datastore.v1.IGqlQueryParameter }|null); + + /** GqlQuery positionalBindings */ + positionalBindings?: (google.datastore.v1.IGqlQueryParameter[]|null); + } + + /** Represents a GqlQuery. */ + class GqlQuery implements IGqlQuery { + + /** + * Constructs a new GqlQuery. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IGqlQuery); + + /** GqlQuery queryString. */ + public queryString: string; + + /** GqlQuery allowLiterals. */ + public allowLiterals: boolean; + + /** GqlQuery namedBindings. */ + public namedBindings: { [k: string]: google.datastore.v1.IGqlQueryParameter }; + + /** GqlQuery positionalBindings. */ + public positionalBindings: google.datastore.v1.IGqlQueryParameter[]; + + /** + * Creates a new GqlQuery instance using the specified properties. + * @param [properties] Properties to set + * @returns GqlQuery instance + */ + public static create(properties?: google.datastore.v1.IGqlQuery): google.datastore.v1.GqlQuery; + + /** + * Encodes the specified GqlQuery message. Does not implicitly {@link google.datastore.v1.GqlQuery.verify|verify} messages. + * @param message GqlQuery message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IGqlQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GqlQuery message, length delimited. Does not implicitly {@link google.datastore.v1.GqlQuery.verify|verify} messages. + * @param message GqlQuery message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IGqlQuery, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GqlQuery message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GqlQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.GqlQuery; + + /** + * Decodes a GqlQuery message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GqlQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.GqlQuery; + + /** + * Verifies a GqlQuery message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GqlQuery message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GqlQuery + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.GqlQuery; + + /** + * Creates a plain object from a GqlQuery message. Also converts values to other types if specified. + * @param message GqlQuery + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.GqlQuery, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GqlQuery to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GqlQuery + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GqlQueryParameter. */ + interface IGqlQueryParameter { + + /** GqlQueryParameter value */ + value?: (google.datastore.v1.IValue|null); + + /** GqlQueryParameter cursor */ + cursor?: (Uint8Array|Buffer|string|null); + } + + /** Represents a GqlQueryParameter. */ + class GqlQueryParameter implements IGqlQueryParameter { + + /** + * Constructs a new GqlQueryParameter. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IGqlQueryParameter); + + /** GqlQueryParameter value. */ + public value?: (google.datastore.v1.IValue|null); + + /** GqlQueryParameter cursor. */ + public cursor?: (Uint8Array|Buffer|string|null); + + /** GqlQueryParameter parameterType. */ + public parameterType?: ("value"|"cursor"); + + /** + * Creates a new GqlQueryParameter instance using the specified properties. + * @param [properties] Properties to set + * @returns GqlQueryParameter instance + */ + public static create(properties?: google.datastore.v1.IGqlQueryParameter): google.datastore.v1.GqlQueryParameter; + + /** + * Encodes the specified GqlQueryParameter message. Does not implicitly {@link google.datastore.v1.GqlQueryParameter.verify|verify} messages. + * @param message GqlQueryParameter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IGqlQueryParameter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GqlQueryParameter message, length delimited. Does not implicitly {@link google.datastore.v1.GqlQueryParameter.verify|verify} messages. + * @param message GqlQueryParameter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IGqlQueryParameter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GqlQueryParameter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GqlQueryParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.GqlQueryParameter; + + /** + * Decodes a GqlQueryParameter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GqlQueryParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.GqlQueryParameter; + + /** + * Verifies a GqlQueryParameter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GqlQueryParameter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GqlQueryParameter + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.GqlQueryParameter; + + /** + * Creates a plain object from a GqlQueryParameter message. Also converts values to other types if specified. + * @param message GqlQueryParameter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.GqlQueryParameter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GqlQueryParameter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GqlQueryParameter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a QueryResultBatch. */ + interface IQueryResultBatch { + + /** QueryResultBatch skippedResults */ + skippedResults?: (number|null); + + /** QueryResultBatch skippedCursor */ + skippedCursor?: (Uint8Array|Buffer|string|null); + + /** QueryResultBatch entityResultType */ + entityResultType?: (google.datastore.v1.EntityResult.ResultType|keyof typeof google.datastore.v1.EntityResult.ResultType|null); + + /** QueryResultBatch entityResults */ + entityResults?: (google.datastore.v1.IEntityResult[]|null); + + /** QueryResultBatch endCursor */ + endCursor?: (Uint8Array|Buffer|string|null); + + /** QueryResultBatch moreResults */ + moreResults?: (google.datastore.v1.QueryResultBatch.MoreResultsType|keyof typeof google.datastore.v1.QueryResultBatch.MoreResultsType|null); + + /** QueryResultBatch snapshotVersion */ + snapshotVersion?: (number|Long|string|null); + + /** QueryResultBatch readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a QueryResultBatch. */ + class QueryResultBatch implements IQueryResultBatch { + + /** + * Constructs a new QueryResultBatch. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IQueryResultBatch); + + /** QueryResultBatch skippedResults. */ + public skippedResults: number; + + /** QueryResultBatch skippedCursor. */ + public skippedCursor: (Uint8Array|Buffer|string); + + /** QueryResultBatch entityResultType. */ + public entityResultType: (google.datastore.v1.EntityResult.ResultType|keyof typeof google.datastore.v1.EntityResult.ResultType); + + /** QueryResultBatch entityResults. */ + public entityResults: google.datastore.v1.IEntityResult[]; + + /** QueryResultBatch endCursor. */ + public endCursor: (Uint8Array|Buffer|string); + + /** QueryResultBatch moreResults. */ + public moreResults: (google.datastore.v1.QueryResultBatch.MoreResultsType|keyof typeof google.datastore.v1.QueryResultBatch.MoreResultsType); + + /** QueryResultBatch snapshotVersion. */ + public snapshotVersion: (number|Long|string); + + /** QueryResultBatch readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new QueryResultBatch instance using the specified properties. + * @param [properties] Properties to set + * @returns QueryResultBatch instance + */ + public static create(properties?: google.datastore.v1.IQueryResultBatch): google.datastore.v1.QueryResultBatch; + + /** + * Encodes the specified QueryResultBatch message. Does not implicitly {@link google.datastore.v1.QueryResultBatch.verify|verify} messages. + * @param message QueryResultBatch message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IQueryResultBatch, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified QueryResultBatch message, length delimited. Does not implicitly {@link google.datastore.v1.QueryResultBatch.verify|verify} messages. + * @param message QueryResultBatch message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IQueryResultBatch, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a QueryResultBatch message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns QueryResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.QueryResultBatch; + + /** + * Decodes a QueryResultBatch message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns QueryResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.QueryResultBatch; + + /** + * Verifies a QueryResultBatch message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a QueryResultBatch message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns QueryResultBatch + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.QueryResultBatch; + + /** + * Creates a plain object from a QueryResultBatch message. Also converts values to other types if specified. + * @param message QueryResultBatch + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.QueryResultBatch, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this QueryResultBatch to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for QueryResultBatch + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace QueryResultBatch { + + /** MoreResultsType enum. */ + enum MoreResultsType { + MORE_RESULTS_TYPE_UNSPECIFIED = 0, + NOT_FINISHED = 1, + MORE_RESULTS_AFTER_LIMIT = 2, + MORE_RESULTS_AFTER_CURSOR = 4, + NO_MORE_RESULTS = 3 + } + } + + /** Represents a Datastore */ + class Datastore extends $protobuf.rpc.Service { + + /** + * Constructs a new Datastore service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Datastore service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Datastore; + + /** + * Calls Lookup. + * @param request LookupRequest message or plain object + * @param callback Node-style callback called with the error, if any, and LookupResponse + */ + public lookup(request: google.datastore.v1.ILookupRequest, callback: google.datastore.v1.Datastore.LookupCallback): void; + + /** + * Calls Lookup. + * @param request LookupRequest message or plain object + * @returns Promise + */ + public lookup(request: google.datastore.v1.ILookupRequest): Promise; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and RunQueryResponse + */ + public runQuery(request: google.datastore.v1.IRunQueryRequest, callback: google.datastore.v1.Datastore.RunQueryCallback): void; + + /** + * Calls RunQuery. + * @param request RunQueryRequest message or plain object + * @returns Promise + */ + public runQuery(request: google.datastore.v1.IRunQueryRequest): Promise; + + /** + * Calls RunAggregationQuery. + * @param request RunAggregationQueryRequest message or plain object + * @param callback Node-style callback called with the error, if any, and RunAggregationQueryResponse + */ + public runAggregationQuery(request: google.datastore.v1.IRunAggregationQueryRequest, callback: google.datastore.v1.Datastore.RunAggregationQueryCallback): void; + + /** + * Calls RunAggregationQuery. + * @param request RunAggregationQueryRequest message or plain object + * @returns Promise + */ + public runAggregationQuery(request: google.datastore.v1.IRunAggregationQueryRequest): Promise; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @param callback Node-style callback called with the error, if any, and BeginTransactionResponse + */ + public beginTransaction(request: google.datastore.v1.IBeginTransactionRequest, callback: google.datastore.v1.Datastore.BeginTransactionCallback): void; + + /** + * Calls BeginTransaction. + * @param request BeginTransactionRequest message or plain object + * @returns Promise + */ + public beginTransaction(request: google.datastore.v1.IBeginTransactionRequest): Promise; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @param callback Node-style callback called with the error, if any, and CommitResponse + */ + public commit(request: google.datastore.v1.ICommitRequest, callback: google.datastore.v1.Datastore.CommitCallback): void; + + /** + * Calls Commit. + * @param request CommitRequest message or plain object + * @returns Promise + */ + public commit(request: google.datastore.v1.ICommitRequest): Promise; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @param callback Node-style callback called with the error, if any, and RollbackResponse + */ + public rollback(request: google.datastore.v1.IRollbackRequest, callback: google.datastore.v1.Datastore.RollbackCallback): void; + + /** + * Calls Rollback. + * @param request RollbackRequest message or plain object + * @returns Promise + */ + public rollback(request: google.datastore.v1.IRollbackRequest): Promise; + + /** + * Calls AllocateIds. + * @param request AllocateIdsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and AllocateIdsResponse + */ + public allocateIds(request: google.datastore.v1.IAllocateIdsRequest, callback: google.datastore.v1.Datastore.AllocateIdsCallback): void; + + /** + * Calls AllocateIds. + * @param request AllocateIdsRequest message or plain object + * @returns Promise + */ + public allocateIds(request: google.datastore.v1.IAllocateIdsRequest): Promise; + + /** + * Calls ReserveIds. + * @param request ReserveIdsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ReserveIdsResponse + */ + public reserveIds(request: google.datastore.v1.IReserveIdsRequest, callback: google.datastore.v1.Datastore.ReserveIdsCallback): void; + + /** + * Calls ReserveIds. + * @param request ReserveIdsRequest message or plain object + * @returns Promise + */ + public reserveIds(request: google.datastore.v1.IReserveIdsRequest): Promise; + } + + namespace Datastore { + + /** + * Callback as used by {@link google.datastore.v1.Datastore|lookup}. + * @param error Error, if any + * @param [response] LookupResponse + */ + type LookupCallback = (error: (Error|null), response?: google.datastore.v1.LookupResponse) => void; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|runQuery}. + * @param error Error, if any + * @param [response] RunQueryResponse + */ + type RunQueryCallback = (error: (Error|null), response?: google.datastore.v1.RunQueryResponse) => void; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|runAggregationQuery}. + * @param error Error, if any + * @param [response] RunAggregationQueryResponse + */ + type RunAggregationQueryCallback = (error: (Error|null), response?: google.datastore.v1.RunAggregationQueryResponse) => void; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|beginTransaction}. + * @param error Error, if any + * @param [response] BeginTransactionResponse + */ + type BeginTransactionCallback = (error: (Error|null), response?: google.datastore.v1.BeginTransactionResponse) => void; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|commit}. + * @param error Error, if any + * @param [response] CommitResponse + */ + type CommitCallback = (error: (Error|null), response?: google.datastore.v1.CommitResponse) => void; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|rollback}. + * @param error Error, if any + * @param [response] RollbackResponse + */ + type RollbackCallback = (error: (Error|null), response?: google.datastore.v1.RollbackResponse) => void; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|allocateIds}. + * @param error Error, if any + * @param [response] AllocateIdsResponse + */ + type AllocateIdsCallback = (error: (Error|null), response?: google.datastore.v1.AllocateIdsResponse) => void; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|reserveIds}. + * @param error Error, if any + * @param [response] ReserveIdsResponse + */ + type ReserveIdsCallback = (error: (Error|null), response?: google.datastore.v1.ReserveIdsResponse) => void; + } + + /** Properties of a LookupRequest. */ + interface ILookupRequest { + + /** LookupRequest projectId */ + projectId?: (string|null); + + /** LookupRequest databaseId */ + databaseId?: (string|null); + + /** LookupRequest readOptions */ + readOptions?: (google.datastore.v1.IReadOptions|null); + + /** LookupRequest keys */ + keys?: (google.datastore.v1.IKey[]|null); + + /** LookupRequest propertyMask */ + propertyMask?: (google.datastore.v1.IPropertyMask|null); + } + + /** Represents a LookupRequest. */ + class LookupRequest implements ILookupRequest { + + /** + * Constructs a new LookupRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.ILookupRequest); + + /** LookupRequest projectId. */ + public projectId: string; + + /** LookupRequest databaseId. */ + public databaseId: string; + + /** LookupRequest readOptions. */ + public readOptions?: (google.datastore.v1.IReadOptions|null); + + /** LookupRequest keys. */ + public keys: google.datastore.v1.IKey[]; + + /** LookupRequest propertyMask. */ + public propertyMask?: (google.datastore.v1.IPropertyMask|null); + + /** + * Creates a new LookupRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns LookupRequest instance + */ + public static create(properties?: google.datastore.v1.ILookupRequest): google.datastore.v1.LookupRequest; + + /** + * Encodes the specified LookupRequest message. Does not implicitly {@link google.datastore.v1.LookupRequest.verify|verify} messages. + * @param message LookupRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.ILookupRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LookupRequest message, length delimited. Does not implicitly {@link google.datastore.v1.LookupRequest.verify|verify} messages. + * @param message LookupRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.ILookupRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LookupRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LookupRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.LookupRequest; + + /** + * Decodes a LookupRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LookupRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.LookupRequest; + + /** + * Verifies a LookupRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LookupRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LookupRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.LookupRequest; + + /** + * Creates a plain object from a LookupRequest message. Also converts values to other types if specified. + * @param message LookupRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.LookupRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LookupRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LookupRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a LookupResponse. */ + interface ILookupResponse { + + /** LookupResponse found */ + found?: (google.datastore.v1.IEntityResult[]|null); + + /** LookupResponse missing */ + missing?: (google.datastore.v1.IEntityResult[]|null); + + /** LookupResponse deferred */ + deferred?: (google.datastore.v1.IKey[]|null); + + /** LookupResponse transaction */ + transaction?: (Uint8Array|Buffer|string|null); + + /** LookupResponse readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a LookupResponse. */ + class LookupResponse implements ILookupResponse { + + /** + * Constructs a new LookupResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.ILookupResponse); + + /** LookupResponse found. */ + public found: google.datastore.v1.IEntityResult[]; + + /** LookupResponse missing. */ + public missing: google.datastore.v1.IEntityResult[]; + + /** LookupResponse deferred. */ + public deferred: google.datastore.v1.IKey[]; + + /** LookupResponse transaction. */ + public transaction: (Uint8Array|Buffer|string); + + /** LookupResponse readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new LookupResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns LookupResponse instance + */ + public static create(properties?: google.datastore.v1.ILookupResponse): google.datastore.v1.LookupResponse; + + /** + * Encodes the specified LookupResponse message. Does not implicitly {@link google.datastore.v1.LookupResponse.verify|verify} messages. + * @param message LookupResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.ILookupResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LookupResponse message, length delimited. Does not implicitly {@link google.datastore.v1.LookupResponse.verify|verify} messages. + * @param message LookupResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.ILookupResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LookupResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LookupResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.LookupResponse; + + /** + * Decodes a LookupResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LookupResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.LookupResponse; + + /** + * Verifies a LookupResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LookupResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LookupResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.LookupResponse; + + /** + * Creates a plain object from a LookupResponse message. Also converts values to other types if specified. + * @param message LookupResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.LookupResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LookupResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LookupResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RunQueryRequest. */ + interface IRunQueryRequest { + + /** RunQueryRequest projectId */ + projectId?: (string|null); + + /** RunQueryRequest databaseId */ + databaseId?: (string|null); + + /** RunQueryRequest partitionId */ + partitionId?: (google.datastore.v1.IPartitionId|null); + + /** RunQueryRequest readOptions */ + readOptions?: (google.datastore.v1.IReadOptions|null); + + /** RunQueryRequest query */ + query?: (google.datastore.v1.IQuery|null); + + /** RunQueryRequest gqlQuery */ + gqlQuery?: (google.datastore.v1.IGqlQuery|null); + + /** RunQueryRequest propertyMask */ + propertyMask?: (google.datastore.v1.IPropertyMask|null); + + /** RunQueryRequest explainOptions */ + explainOptions?: (google.datastore.v1.IExplainOptions|null); + } + + /** Represents a RunQueryRequest. */ + class RunQueryRequest implements IRunQueryRequest { + + /** + * Constructs a new RunQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IRunQueryRequest); + + /** RunQueryRequest projectId. */ + public projectId: string; + + /** RunQueryRequest databaseId. */ + public databaseId: string; + + /** RunQueryRequest partitionId. */ + public partitionId?: (google.datastore.v1.IPartitionId|null); + + /** RunQueryRequest readOptions. */ + public readOptions?: (google.datastore.v1.IReadOptions|null); + + /** RunQueryRequest query. */ + public query?: (google.datastore.v1.IQuery|null); + + /** RunQueryRequest gqlQuery. */ + public gqlQuery?: (google.datastore.v1.IGqlQuery|null); + + /** RunQueryRequest propertyMask. */ + public propertyMask?: (google.datastore.v1.IPropertyMask|null); + + /** RunQueryRequest explainOptions. */ + public explainOptions?: (google.datastore.v1.IExplainOptions|null); + + /** RunQueryRequest queryType. */ + public queryType?: ("query"|"gqlQuery"); + + /** + * Creates a new RunQueryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RunQueryRequest instance + */ + public static create(properties?: google.datastore.v1.IRunQueryRequest): google.datastore.v1.RunQueryRequest; + + /** + * Encodes the specified RunQueryRequest message. Does not implicitly {@link google.datastore.v1.RunQueryRequest.verify|verify} messages. + * @param message RunQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IRunQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RunQueryRequest message, length delimited. Does not implicitly {@link google.datastore.v1.RunQueryRequest.verify|verify} messages. + * @param message RunQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IRunQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.RunQueryRequest; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.RunQueryRequest; + + /** + * Verifies a RunQueryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.RunQueryRequest; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @param message RunQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.RunQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RunQueryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RunQueryResponse. */ + interface IRunQueryResponse { + + /** RunQueryResponse batch */ + batch?: (google.datastore.v1.IQueryResultBatch|null); + + /** RunQueryResponse query */ + query?: (google.datastore.v1.IQuery|null); + + /** RunQueryResponse transaction */ + transaction?: (Uint8Array|Buffer|string|null); + + /** RunQueryResponse explainMetrics */ + explainMetrics?: (google.datastore.v1.IExplainMetrics|null); + } + + /** Represents a RunQueryResponse. */ + class RunQueryResponse implements IRunQueryResponse { + + /** + * Constructs a new RunQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IRunQueryResponse); + + /** RunQueryResponse batch. */ + public batch?: (google.datastore.v1.IQueryResultBatch|null); + + /** RunQueryResponse query. */ + public query?: (google.datastore.v1.IQuery|null); + + /** RunQueryResponse transaction. */ + public transaction: (Uint8Array|Buffer|string); + + /** RunQueryResponse explainMetrics. */ + public explainMetrics?: (google.datastore.v1.IExplainMetrics|null); + + /** + * Creates a new RunQueryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RunQueryResponse instance + */ + public static create(properties?: google.datastore.v1.IRunQueryResponse): google.datastore.v1.RunQueryResponse; + + /** + * Encodes the specified RunQueryResponse message. Does not implicitly {@link google.datastore.v1.RunQueryResponse.verify|verify} messages. + * @param message RunQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IRunQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RunQueryResponse message, length delimited. Does not implicitly {@link google.datastore.v1.RunQueryResponse.verify|verify} messages. + * @param message RunQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IRunQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.RunQueryResponse; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.RunQueryResponse; + + /** + * Verifies a RunQueryResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.RunQueryResponse; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @param message RunQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.RunQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RunQueryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RunAggregationQueryRequest. */ + interface IRunAggregationQueryRequest { + + /** RunAggregationQueryRequest projectId */ + projectId?: (string|null); + + /** RunAggregationQueryRequest databaseId */ + databaseId?: (string|null); + + /** RunAggregationQueryRequest partitionId */ + partitionId?: (google.datastore.v1.IPartitionId|null); + + /** RunAggregationQueryRequest readOptions */ + readOptions?: (google.datastore.v1.IReadOptions|null); + + /** RunAggregationQueryRequest aggregationQuery */ + aggregationQuery?: (google.datastore.v1.IAggregationQuery|null); + + /** RunAggregationQueryRequest gqlQuery */ + gqlQuery?: (google.datastore.v1.IGqlQuery|null); + + /** RunAggregationQueryRequest explainOptions */ + explainOptions?: (google.datastore.v1.IExplainOptions|null); + } + + /** Represents a RunAggregationQueryRequest. */ + class RunAggregationQueryRequest implements IRunAggregationQueryRequest { + + /** + * Constructs a new RunAggregationQueryRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IRunAggregationQueryRequest); + + /** RunAggregationQueryRequest projectId. */ + public projectId: string; + + /** RunAggregationQueryRequest databaseId. */ + public databaseId: string; + + /** RunAggregationQueryRequest partitionId. */ + public partitionId?: (google.datastore.v1.IPartitionId|null); + + /** RunAggregationQueryRequest readOptions. */ + public readOptions?: (google.datastore.v1.IReadOptions|null); + + /** RunAggregationQueryRequest aggregationQuery. */ + public aggregationQuery?: (google.datastore.v1.IAggregationQuery|null); + + /** RunAggregationQueryRequest gqlQuery. */ + public gqlQuery?: (google.datastore.v1.IGqlQuery|null); + + /** RunAggregationQueryRequest explainOptions. */ + public explainOptions?: (google.datastore.v1.IExplainOptions|null); + + /** RunAggregationQueryRequest queryType. */ + public queryType?: ("aggregationQuery"|"gqlQuery"); + + /** + * Creates a new RunAggregationQueryRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RunAggregationQueryRequest instance + */ + public static create(properties?: google.datastore.v1.IRunAggregationQueryRequest): google.datastore.v1.RunAggregationQueryRequest; + + /** + * Encodes the specified RunAggregationQueryRequest message. Does not implicitly {@link google.datastore.v1.RunAggregationQueryRequest.verify|verify} messages. + * @param message RunAggregationQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IRunAggregationQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RunAggregationQueryRequest message, length delimited. Does not implicitly {@link google.datastore.v1.RunAggregationQueryRequest.verify|verify} messages. + * @param message RunAggregationQueryRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IRunAggregationQueryRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RunAggregationQueryRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RunAggregationQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.RunAggregationQueryRequest; + + /** + * Decodes a RunAggregationQueryRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RunAggregationQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.RunAggregationQueryRequest; + + /** + * Verifies a RunAggregationQueryRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RunAggregationQueryRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunAggregationQueryRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.RunAggregationQueryRequest; + + /** + * Creates a plain object from a RunAggregationQueryRequest message. Also converts values to other types if specified. + * @param message RunAggregationQueryRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.RunAggregationQueryRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunAggregationQueryRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RunAggregationQueryRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RunAggregationQueryResponse. */ + interface IRunAggregationQueryResponse { + + /** RunAggregationQueryResponse batch */ + batch?: (google.datastore.v1.IAggregationResultBatch|null); + + /** RunAggregationQueryResponse query */ + query?: (google.datastore.v1.IAggregationQuery|null); + + /** RunAggregationQueryResponse transaction */ + transaction?: (Uint8Array|Buffer|string|null); + + /** RunAggregationQueryResponse explainMetrics */ + explainMetrics?: (google.datastore.v1.IExplainMetrics|null); + } + + /** Represents a RunAggregationQueryResponse. */ + class RunAggregationQueryResponse implements IRunAggregationQueryResponse { + + /** + * Constructs a new RunAggregationQueryResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IRunAggregationQueryResponse); + + /** RunAggregationQueryResponse batch. */ + public batch?: (google.datastore.v1.IAggregationResultBatch|null); + + /** RunAggregationQueryResponse query. */ + public query?: (google.datastore.v1.IAggregationQuery|null); + + /** RunAggregationQueryResponse transaction. */ + public transaction: (Uint8Array|Buffer|string); + + /** RunAggregationQueryResponse explainMetrics. */ + public explainMetrics?: (google.datastore.v1.IExplainMetrics|null); + + /** + * Creates a new RunAggregationQueryResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RunAggregationQueryResponse instance + */ + public static create(properties?: google.datastore.v1.IRunAggregationQueryResponse): google.datastore.v1.RunAggregationQueryResponse; + + /** + * Encodes the specified RunAggregationQueryResponse message. Does not implicitly {@link google.datastore.v1.RunAggregationQueryResponse.verify|verify} messages. + * @param message RunAggregationQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IRunAggregationQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RunAggregationQueryResponse message, length delimited. Does not implicitly {@link google.datastore.v1.RunAggregationQueryResponse.verify|verify} messages. + * @param message RunAggregationQueryResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IRunAggregationQueryResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RunAggregationQueryResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RunAggregationQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.RunAggregationQueryResponse; + + /** + * Decodes a RunAggregationQueryResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RunAggregationQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.RunAggregationQueryResponse; + + /** + * Verifies a RunAggregationQueryResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RunAggregationQueryResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RunAggregationQueryResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.RunAggregationQueryResponse; + + /** + * Creates a plain object from a RunAggregationQueryResponse message. Also converts values to other types if specified. + * @param message RunAggregationQueryResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.RunAggregationQueryResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RunAggregationQueryResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RunAggregationQueryResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BeginTransactionRequest. */ + interface IBeginTransactionRequest { + + /** BeginTransactionRequest projectId */ + projectId?: (string|null); + + /** BeginTransactionRequest databaseId */ + databaseId?: (string|null); + + /** BeginTransactionRequest transactionOptions */ + transactionOptions?: (google.datastore.v1.ITransactionOptions|null); + } + + /** Represents a BeginTransactionRequest. */ + class BeginTransactionRequest implements IBeginTransactionRequest { + + /** + * Constructs a new BeginTransactionRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IBeginTransactionRequest); + + /** BeginTransactionRequest projectId. */ + public projectId: string; + + /** BeginTransactionRequest databaseId. */ + public databaseId: string; + + /** BeginTransactionRequest transactionOptions. */ + public transactionOptions?: (google.datastore.v1.ITransactionOptions|null); + + /** + * Creates a new BeginTransactionRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns BeginTransactionRequest instance + */ + public static create(properties?: google.datastore.v1.IBeginTransactionRequest): google.datastore.v1.BeginTransactionRequest; + + /** + * Encodes the specified BeginTransactionRequest message. Does not implicitly {@link google.datastore.v1.BeginTransactionRequest.verify|verify} messages. + * @param message BeginTransactionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IBeginTransactionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BeginTransactionRequest message, length delimited. Does not implicitly {@link google.datastore.v1.BeginTransactionRequest.verify|verify} messages. + * @param message BeginTransactionRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IBeginTransactionRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.BeginTransactionRequest; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.BeginTransactionRequest; + + /** + * Verifies a BeginTransactionRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.BeginTransactionRequest; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @param message BeginTransactionRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.BeginTransactionRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BeginTransactionRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BeginTransactionResponse. */ + interface IBeginTransactionResponse { + + /** BeginTransactionResponse transaction */ + transaction?: (Uint8Array|Buffer|string|null); + } + + /** Represents a BeginTransactionResponse. */ + class BeginTransactionResponse implements IBeginTransactionResponse { + + /** + * Constructs a new BeginTransactionResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IBeginTransactionResponse); + + /** BeginTransactionResponse transaction. */ + public transaction: (Uint8Array|Buffer|string); + + /** + * Creates a new BeginTransactionResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns BeginTransactionResponse instance + */ + public static create(properties?: google.datastore.v1.IBeginTransactionResponse): google.datastore.v1.BeginTransactionResponse; + + /** + * Encodes the specified BeginTransactionResponse message. Does not implicitly {@link google.datastore.v1.BeginTransactionResponse.verify|verify} messages. + * @param message BeginTransactionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IBeginTransactionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BeginTransactionResponse message, length delimited. Does not implicitly {@link google.datastore.v1.BeginTransactionResponse.verify|verify} messages. + * @param message BeginTransactionResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IBeginTransactionResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.BeginTransactionResponse; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.BeginTransactionResponse; + + /** + * Verifies a BeginTransactionResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BeginTransactionResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.BeginTransactionResponse; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @param message BeginTransactionResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.BeginTransactionResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BeginTransactionResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RollbackRequest. */ + interface IRollbackRequest { + + /** RollbackRequest projectId */ + projectId?: (string|null); + + /** RollbackRequest databaseId */ + databaseId?: (string|null); + + /** RollbackRequest transaction */ + transaction?: (Uint8Array|Buffer|string|null); + } + + /** Represents a RollbackRequest. */ + class RollbackRequest implements IRollbackRequest { + + /** + * Constructs a new RollbackRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IRollbackRequest); + + /** RollbackRequest projectId. */ + public projectId: string; + + /** RollbackRequest databaseId. */ + public databaseId: string; + + /** RollbackRequest transaction. */ + public transaction: (Uint8Array|Buffer|string); + + /** + * Creates a new RollbackRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns RollbackRequest instance + */ + public static create(properties?: google.datastore.v1.IRollbackRequest): google.datastore.v1.RollbackRequest; + + /** + * Encodes the specified RollbackRequest message. Does not implicitly {@link google.datastore.v1.RollbackRequest.verify|verify} messages. + * @param message RollbackRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IRollbackRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RollbackRequest message, length delimited. Does not implicitly {@link google.datastore.v1.RollbackRequest.verify|verify} messages. + * @param message RollbackRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IRollbackRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.RollbackRequest; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.RollbackRequest; + + /** + * Verifies a RollbackRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RollbackRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.RollbackRequest; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @param message RollbackRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.RollbackRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RollbackRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RollbackRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RollbackResponse. */ + interface IRollbackResponse { + } + + /** Represents a RollbackResponse. */ + class RollbackResponse implements IRollbackResponse { + + /** + * Constructs a new RollbackResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IRollbackResponse); + + /** + * Creates a new RollbackResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns RollbackResponse instance + */ + public static create(properties?: google.datastore.v1.IRollbackResponse): google.datastore.v1.RollbackResponse; + + /** + * Encodes the specified RollbackResponse message. Does not implicitly {@link google.datastore.v1.RollbackResponse.verify|verify} messages. + * @param message RollbackResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IRollbackResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RollbackResponse message, length delimited. Does not implicitly {@link google.datastore.v1.RollbackResponse.verify|verify} messages. + * @param message RollbackResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IRollbackResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RollbackResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RollbackResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.RollbackResponse; + + /** + * Decodes a RollbackResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RollbackResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.RollbackResponse; + + /** + * Verifies a RollbackResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RollbackResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RollbackResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.RollbackResponse; + + /** + * Creates a plain object from a RollbackResponse message. Also converts values to other types if specified. + * @param message RollbackResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.RollbackResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RollbackResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RollbackResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CommitRequest. */ + interface ICommitRequest { + + /** CommitRequest projectId */ + projectId?: (string|null); + + /** CommitRequest databaseId */ + databaseId?: (string|null); + + /** CommitRequest mode */ + mode?: (google.datastore.v1.CommitRequest.Mode|keyof typeof google.datastore.v1.CommitRequest.Mode|null); + + /** CommitRequest transaction */ + transaction?: (Uint8Array|Buffer|string|null); + + /** CommitRequest singleUseTransaction */ + singleUseTransaction?: (google.datastore.v1.ITransactionOptions|null); + + /** CommitRequest mutations */ + mutations?: (google.datastore.v1.IMutation[]|null); + } + + /** Represents a CommitRequest. */ + class CommitRequest implements ICommitRequest { + + /** + * Constructs a new CommitRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.ICommitRequest); + + /** CommitRequest projectId. */ + public projectId: string; + + /** CommitRequest databaseId. */ + public databaseId: string; + + /** CommitRequest mode. */ + public mode: (google.datastore.v1.CommitRequest.Mode|keyof typeof google.datastore.v1.CommitRequest.Mode); + + /** CommitRequest transaction. */ + public transaction?: (Uint8Array|Buffer|string|null); + + /** CommitRequest singleUseTransaction. */ + public singleUseTransaction?: (google.datastore.v1.ITransactionOptions|null); + + /** CommitRequest mutations. */ + public mutations: google.datastore.v1.IMutation[]; + + /** CommitRequest transactionSelector. */ + public transactionSelector?: ("transaction"|"singleUseTransaction"); + + /** + * Creates a new CommitRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CommitRequest instance + */ + public static create(properties?: google.datastore.v1.ICommitRequest): google.datastore.v1.CommitRequest; + + /** + * Encodes the specified CommitRequest message. Does not implicitly {@link google.datastore.v1.CommitRequest.verify|verify} messages. + * @param message CommitRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.ICommitRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CommitRequest message, length delimited. Does not implicitly {@link google.datastore.v1.CommitRequest.verify|verify} messages. + * @param message CommitRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.ICommitRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommitRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.CommitRequest; + + /** + * Decodes a CommitRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.CommitRequest; + + /** + * Verifies a CommitRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.CommitRequest; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @param message CommitRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.CommitRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CommitRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace CommitRequest { + + /** Mode enum. */ + enum Mode { + MODE_UNSPECIFIED = 0, + TRANSACTIONAL = 1, + NON_TRANSACTIONAL = 2 + } + } + + /** Properties of a CommitResponse. */ + interface ICommitResponse { + + /** CommitResponse mutationResults */ + mutationResults?: (google.datastore.v1.IMutationResult[]|null); + + /** CommitResponse indexUpdates */ + indexUpdates?: (number|null); + + /** CommitResponse commitTime */ + commitTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a CommitResponse. */ + class CommitResponse implements ICommitResponse { + + /** + * Constructs a new CommitResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.ICommitResponse); + + /** CommitResponse mutationResults. */ + public mutationResults: google.datastore.v1.IMutationResult[]; + + /** CommitResponse indexUpdates. */ + public indexUpdates: number; + + /** CommitResponse commitTime. */ + public commitTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new CommitResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns CommitResponse instance + */ + public static create(properties?: google.datastore.v1.ICommitResponse): google.datastore.v1.CommitResponse; + + /** + * Encodes the specified CommitResponse message. Does not implicitly {@link google.datastore.v1.CommitResponse.verify|verify} messages. + * @param message CommitResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.ICommitResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CommitResponse message, length delimited. Does not implicitly {@link google.datastore.v1.CommitResponse.verify|verify} messages. + * @param message CommitResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.ICommitResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommitResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.CommitResponse; + + /** + * Decodes a CommitResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.CommitResponse; + + /** + * Verifies a CommitResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommitResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.CommitResponse; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @param message CommitResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.CommitResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommitResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CommitResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AllocateIdsRequest. */ + interface IAllocateIdsRequest { + + /** AllocateIdsRequest projectId */ + projectId?: (string|null); + + /** AllocateIdsRequest databaseId */ + databaseId?: (string|null); + + /** AllocateIdsRequest keys */ + keys?: (google.datastore.v1.IKey[]|null); + } + + /** Represents an AllocateIdsRequest. */ + class AllocateIdsRequest implements IAllocateIdsRequest { + + /** + * Constructs a new AllocateIdsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IAllocateIdsRequest); + + /** AllocateIdsRequest projectId. */ + public projectId: string; + + /** AllocateIdsRequest databaseId. */ + public databaseId: string; + + /** AllocateIdsRequest keys. */ + public keys: google.datastore.v1.IKey[]; + + /** + * Creates a new AllocateIdsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns AllocateIdsRequest instance + */ + public static create(properties?: google.datastore.v1.IAllocateIdsRequest): google.datastore.v1.AllocateIdsRequest; + + /** + * Encodes the specified AllocateIdsRequest message. Does not implicitly {@link google.datastore.v1.AllocateIdsRequest.verify|verify} messages. + * @param message AllocateIdsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IAllocateIdsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AllocateIdsRequest message, length delimited. Does not implicitly {@link google.datastore.v1.AllocateIdsRequest.verify|verify} messages. + * @param message AllocateIdsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IAllocateIdsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AllocateIdsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AllocateIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AllocateIdsRequest; + + /** + * Decodes an AllocateIdsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AllocateIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AllocateIdsRequest; + + /** + * Verifies an AllocateIdsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AllocateIdsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AllocateIdsRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AllocateIdsRequest; + + /** + * Creates a plain object from an AllocateIdsRequest message. Also converts values to other types if specified. + * @param message AllocateIdsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AllocateIdsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AllocateIdsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AllocateIdsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an AllocateIdsResponse. */ + interface IAllocateIdsResponse { + + /** AllocateIdsResponse keys */ + keys?: (google.datastore.v1.IKey[]|null); + } + + /** Represents an AllocateIdsResponse. */ + class AllocateIdsResponse implements IAllocateIdsResponse { + + /** + * Constructs a new AllocateIdsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IAllocateIdsResponse); + + /** AllocateIdsResponse keys. */ + public keys: google.datastore.v1.IKey[]; + + /** + * Creates a new AllocateIdsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns AllocateIdsResponse instance + */ + public static create(properties?: google.datastore.v1.IAllocateIdsResponse): google.datastore.v1.AllocateIdsResponse; + + /** + * Encodes the specified AllocateIdsResponse message. Does not implicitly {@link google.datastore.v1.AllocateIdsResponse.verify|verify} messages. + * @param message AllocateIdsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IAllocateIdsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified AllocateIdsResponse message, length delimited. Does not implicitly {@link google.datastore.v1.AllocateIdsResponse.verify|verify} messages. + * @param message AllocateIdsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IAllocateIdsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an AllocateIdsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns AllocateIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.AllocateIdsResponse; + + /** + * Decodes an AllocateIdsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns AllocateIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.AllocateIdsResponse; + + /** + * Verifies an AllocateIdsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an AllocateIdsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns AllocateIdsResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.AllocateIdsResponse; + + /** + * Creates a plain object from an AllocateIdsResponse message. Also converts values to other types if specified. + * @param message AllocateIdsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.AllocateIdsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this AllocateIdsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for AllocateIdsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReserveIdsRequest. */ + interface IReserveIdsRequest { + + /** ReserveIdsRequest projectId */ + projectId?: (string|null); + + /** ReserveIdsRequest databaseId */ + databaseId?: (string|null); + + /** ReserveIdsRequest keys */ + keys?: (google.datastore.v1.IKey[]|null); + } + + /** Represents a ReserveIdsRequest. */ + class ReserveIdsRequest implements IReserveIdsRequest { + + /** + * Constructs a new ReserveIdsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IReserveIdsRequest); + + /** ReserveIdsRequest projectId. */ + public projectId: string; + + /** ReserveIdsRequest databaseId. */ + public databaseId: string; + + /** ReserveIdsRequest keys. */ + public keys: google.datastore.v1.IKey[]; + + /** + * Creates a new ReserveIdsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ReserveIdsRequest instance + */ + public static create(properties?: google.datastore.v1.IReserveIdsRequest): google.datastore.v1.ReserveIdsRequest; + + /** + * Encodes the specified ReserveIdsRequest message. Does not implicitly {@link google.datastore.v1.ReserveIdsRequest.verify|verify} messages. + * @param message ReserveIdsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IReserveIdsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReserveIdsRequest message, length delimited. Does not implicitly {@link google.datastore.v1.ReserveIdsRequest.verify|verify} messages. + * @param message ReserveIdsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IReserveIdsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReserveIdsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReserveIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.ReserveIdsRequest; + + /** + * Decodes a ReserveIdsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReserveIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.ReserveIdsRequest; + + /** + * Verifies a ReserveIdsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReserveIdsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReserveIdsRequest + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.ReserveIdsRequest; + + /** + * Creates a plain object from a ReserveIdsRequest message. Also converts values to other types if specified. + * @param message ReserveIdsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.ReserveIdsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReserveIdsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReserveIdsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReserveIdsResponse. */ + interface IReserveIdsResponse { + } + + /** Represents a ReserveIdsResponse. */ + class ReserveIdsResponse implements IReserveIdsResponse { + + /** + * Constructs a new ReserveIdsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IReserveIdsResponse); + + /** + * Creates a new ReserveIdsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ReserveIdsResponse instance + */ + public static create(properties?: google.datastore.v1.IReserveIdsResponse): google.datastore.v1.ReserveIdsResponse; + + /** + * Encodes the specified ReserveIdsResponse message. Does not implicitly {@link google.datastore.v1.ReserveIdsResponse.verify|verify} messages. + * @param message ReserveIdsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IReserveIdsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReserveIdsResponse message, length delimited. Does not implicitly {@link google.datastore.v1.ReserveIdsResponse.verify|verify} messages. + * @param message ReserveIdsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IReserveIdsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReserveIdsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReserveIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.ReserveIdsResponse; + + /** + * Decodes a ReserveIdsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReserveIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.ReserveIdsResponse; + + /** + * Verifies a ReserveIdsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReserveIdsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReserveIdsResponse + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.ReserveIdsResponse; + + /** + * Creates a plain object from a ReserveIdsResponse message. Also converts values to other types if specified. + * @param message ReserveIdsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.ReserveIdsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReserveIdsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReserveIdsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Mutation. */ + interface IMutation { + + /** Mutation insert */ + insert?: (google.datastore.v1.IEntity|null); + + /** Mutation update */ + update?: (google.datastore.v1.IEntity|null); + + /** Mutation upsert */ + upsert?: (google.datastore.v1.IEntity|null); + + /** Mutation delete */ + "delete"?: (google.datastore.v1.IKey|null); + + /** Mutation baseVersion */ + baseVersion?: (number|Long|string|null); + + /** Mutation updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** Mutation conflictResolutionStrategy */ + conflictResolutionStrategy?: (google.datastore.v1.Mutation.ConflictResolutionStrategy|keyof typeof google.datastore.v1.Mutation.ConflictResolutionStrategy|null); + + /** Mutation propertyMask */ + propertyMask?: (google.datastore.v1.IPropertyMask|null); + + /** Mutation propertyTransforms */ + propertyTransforms?: (google.datastore.v1.IPropertyTransform[]|null); + } + + /** Represents a Mutation. */ + class Mutation implements IMutation { + + /** + * Constructs a new Mutation. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IMutation); + + /** Mutation insert. */ + public insert?: (google.datastore.v1.IEntity|null); + + /** Mutation update. */ + public update?: (google.datastore.v1.IEntity|null); + + /** Mutation upsert. */ + public upsert?: (google.datastore.v1.IEntity|null); + + /** Mutation delete. */ + public delete?: (google.datastore.v1.IKey|null); + + /** Mutation baseVersion. */ + public baseVersion?: (number|Long|string|null); + + /** Mutation updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** Mutation conflictResolutionStrategy. */ + public conflictResolutionStrategy: (google.datastore.v1.Mutation.ConflictResolutionStrategy|keyof typeof google.datastore.v1.Mutation.ConflictResolutionStrategy); + + /** Mutation propertyMask. */ + public propertyMask?: (google.datastore.v1.IPropertyMask|null); + + /** Mutation propertyTransforms. */ + public propertyTransforms: google.datastore.v1.IPropertyTransform[]; + + /** Mutation operation. */ + public operation?: ("insert"|"update"|"upsert"|"delete"); + + /** Mutation conflictDetectionStrategy. */ + public conflictDetectionStrategy?: ("baseVersion"|"updateTime"); + + /** + * Creates a new Mutation instance using the specified properties. + * @param [properties] Properties to set + * @returns Mutation instance + */ + public static create(properties?: google.datastore.v1.IMutation): google.datastore.v1.Mutation; + + /** + * Encodes the specified Mutation message. Does not implicitly {@link google.datastore.v1.Mutation.verify|verify} messages. + * @param message Mutation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IMutation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Mutation message, length delimited. Does not implicitly {@link google.datastore.v1.Mutation.verify|verify} messages. + * @param message Mutation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IMutation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Mutation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Mutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.Mutation; + + /** + * Decodes a Mutation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Mutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.Mutation; + + /** + * Verifies a Mutation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Mutation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Mutation + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.Mutation; + + /** + * Creates a plain object from a Mutation message. Also converts values to other types if specified. + * @param message Mutation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.Mutation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Mutation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Mutation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Mutation { + + /** ConflictResolutionStrategy enum. */ + enum ConflictResolutionStrategy { + STRATEGY_UNSPECIFIED = 0, + SERVER_VALUE = 1, + FAIL = 3 + } + } + + /** Properties of a PropertyTransform. */ + interface IPropertyTransform { + + /** PropertyTransform property */ + property?: (string|null); + + /** PropertyTransform setToServerValue */ + setToServerValue?: (google.datastore.v1.PropertyTransform.ServerValue|keyof typeof google.datastore.v1.PropertyTransform.ServerValue|null); + + /** PropertyTransform increment */ + increment?: (google.datastore.v1.IValue|null); + + /** PropertyTransform maximum */ + maximum?: (google.datastore.v1.IValue|null); + + /** PropertyTransform minimum */ + minimum?: (google.datastore.v1.IValue|null); + + /** PropertyTransform appendMissingElements */ + appendMissingElements?: (google.datastore.v1.IArrayValue|null); + + /** PropertyTransform removeAllFromArray */ + removeAllFromArray?: (google.datastore.v1.IArrayValue|null); + } + + /** Represents a PropertyTransform. */ + class PropertyTransform implements IPropertyTransform { + + /** + * Constructs a new PropertyTransform. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IPropertyTransform); + + /** PropertyTransform property. */ + public property: string; + + /** PropertyTransform setToServerValue. */ + public setToServerValue?: (google.datastore.v1.PropertyTransform.ServerValue|keyof typeof google.datastore.v1.PropertyTransform.ServerValue|null); + + /** PropertyTransform increment. */ + public increment?: (google.datastore.v1.IValue|null); + + /** PropertyTransform maximum. */ + public maximum?: (google.datastore.v1.IValue|null); + + /** PropertyTransform minimum. */ + public minimum?: (google.datastore.v1.IValue|null); + + /** PropertyTransform appendMissingElements. */ + public appendMissingElements?: (google.datastore.v1.IArrayValue|null); + + /** PropertyTransform removeAllFromArray. */ + public removeAllFromArray?: (google.datastore.v1.IArrayValue|null); + + /** PropertyTransform transformType. */ + public transformType?: ("setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"); + + /** + * Creates a new PropertyTransform instance using the specified properties. + * @param [properties] Properties to set + * @returns PropertyTransform instance + */ + public static create(properties?: google.datastore.v1.IPropertyTransform): google.datastore.v1.PropertyTransform; + + /** + * Encodes the specified PropertyTransform message. Does not implicitly {@link google.datastore.v1.PropertyTransform.verify|verify} messages. + * @param message PropertyTransform message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IPropertyTransform, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PropertyTransform message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyTransform.verify|verify} messages. + * @param message PropertyTransform message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IPropertyTransform, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PropertyTransform message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PropertyTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.PropertyTransform; + + /** + * Decodes a PropertyTransform message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PropertyTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.PropertyTransform; + + /** + * Verifies a PropertyTransform message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PropertyTransform message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PropertyTransform + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.PropertyTransform; + + /** + * Creates a plain object from a PropertyTransform message. Also converts values to other types if specified. + * @param message PropertyTransform + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.PropertyTransform, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PropertyTransform to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PropertyTransform + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PropertyTransform { + + /** ServerValue enum. */ + enum ServerValue { + SERVER_VALUE_UNSPECIFIED = 0, + REQUEST_TIME = 1 + } + } + + /** Properties of a MutationResult. */ + interface IMutationResult { + + /** MutationResult key */ + key?: (google.datastore.v1.IKey|null); + + /** MutationResult version */ + version?: (number|Long|string|null); + + /** MutationResult createTime */ + createTime?: (google.protobuf.ITimestamp|null); + + /** MutationResult updateTime */ + updateTime?: (google.protobuf.ITimestamp|null); + + /** MutationResult conflictDetected */ + conflictDetected?: (boolean|null); + + /** MutationResult transformResults */ + transformResults?: (google.datastore.v1.IValue[]|null); + } + + /** Represents a MutationResult. */ + class MutationResult implements IMutationResult { + + /** + * Constructs a new MutationResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IMutationResult); + + /** MutationResult key. */ + public key?: (google.datastore.v1.IKey|null); + + /** MutationResult version. */ + public version: (number|Long|string); + + /** MutationResult createTime. */ + public createTime?: (google.protobuf.ITimestamp|null); + + /** MutationResult updateTime. */ + public updateTime?: (google.protobuf.ITimestamp|null); + + /** MutationResult conflictDetected. */ + public conflictDetected: boolean; + + /** MutationResult transformResults. */ + public transformResults: google.datastore.v1.IValue[]; + + /** + * Creates a new MutationResult instance using the specified properties. + * @param [properties] Properties to set + * @returns MutationResult instance + */ + public static create(properties?: google.datastore.v1.IMutationResult): google.datastore.v1.MutationResult; + + /** + * Encodes the specified MutationResult message. Does not implicitly {@link google.datastore.v1.MutationResult.verify|verify} messages. + * @param message MutationResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IMutationResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MutationResult message, length delimited. Does not implicitly {@link google.datastore.v1.MutationResult.verify|verify} messages. + * @param message MutationResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IMutationResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MutationResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MutationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.MutationResult; + + /** + * Decodes a MutationResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MutationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.MutationResult; + + /** + * Verifies a MutationResult message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MutationResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MutationResult + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.MutationResult; + + /** + * Creates a plain object from a MutationResult message. Also converts values to other types if specified. + * @param message MutationResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.MutationResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MutationResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MutationResult + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PropertyMask. */ + interface IPropertyMask { + + /** PropertyMask paths */ + paths?: (string[]|null); + } + + /** Represents a PropertyMask. */ + class PropertyMask implements IPropertyMask { + + /** + * Constructs a new PropertyMask. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IPropertyMask); + + /** PropertyMask paths. */ + public paths: string[]; + + /** + * Creates a new PropertyMask instance using the specified properties. + * @param [properties] Properties to set + * @returns PropertyMask instance + */ + public static create(properties?: google.datastore.v1.IPropertyMask): google.datastore.v1.PropertyMask; + + /** + * Encodes the specified PropertyMask message. Does not implicitly {@link google.datastore.v1.PropertyMask.verify|verify} messages. + * @param message PropertyMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IPropertyMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PropertyMask message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyMask.verify|verify} messages. + * @param message PropertyMask message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IPropertyMask, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PropertyMask message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PropertyMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.PropertyMask; + + /** + * Decodes a PropertyMask message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PropertyMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.PropertyMask; + + /** + * Verifies a PropertyMask message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PropertyMask message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PropertyMask + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.PropertyMask; + + /** + * Creates a plain object from a PropertyMask message. Also converts values to other types if specified. + * @param message PropertyMask + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.PropertyMask, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PropertyMask to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PropertyMask + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReadOptions. */ + interface IReadOptions { + + /** ReadOptions readConsistency */ + readConsistency?: (google.datastore.v1.ReadOptions.ReadConsistency|keyof typeof google.datastore.v1.ReadOptions.ReadConsistency|null); + + /** ReadOptions transaction */ + transaction?: (Uint8Array|Buffer|string|null); + + /** ReadOptions newTransaction */ + newTransaction?: (google.datastore.v1.ITransactionOptions|null); + + /** ReadOptions readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a ReadOptions. */ + class ReadOptions implements IReadOptions { + + /** + * Constructs a new ReadOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IReadOptions); + + /** ReadOptions readConsistency. */ + public readConsistency?: (google.datastore.v1.ReadOptions.ReadConsistency|keyof typeof google.datastore.v1.ReadOptions.ReadConsistency|null); + + /** ReadOptions transaction. */ + public transaction?: (Uint8Array|Buffer|string|null); + + /** ReadOptions newTransaction. */ + public newTransaction?: (google.datastore.v1.ITransactionOptions|null); + + /** ReadOptions readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** ReadOptions consistencyType. */ + public consistencyType?: ("readConsistency"|"transaction"|"newTransaction"|"readTime"); + + /** + * Creates a new ReadOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns ReadOptions instance + */ + public static create(properties?: google.datastore.v1.IReadOptions): google.datastore.v1.ReadOptions; + + /** + * Encodes the specified ReadOptions message. Does not implicitly {@link google.datastore.v1.ReadOptions.verify|verify} messages. + * @param message ReadOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IReadOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReadOptions message, length delimited. Does not implicitly {@link google.datastore.v1.ReadOptions.verify|verify} messages. + * @param message ReadOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IReadOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReadOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReadOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.ReadOptions; + + /** + * Decodes a ReadOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReadOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.ReadOptions; + + /** + * Verifies a ReadOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReadOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadOptions + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.ReadOptions; + + /** + * Creates a plain object from a ReadOptions message. Also converts values to other types if specified. + * @param message ReadOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.ReadOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReadOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ReadOptions { + + /** ReadConsistency enum. */ + enum ReadConsistency { + READ_CONSISTENCY_UNSPECIFIED = 0, + STRONG = 1, + EVENTUAL = 2 + } + } + + /** Properties of a TransactionOptions. */ + interface ITransactionOptions { + + /** TransactionOptions readWrite */ + readWrite?: (google.datastore.v1.TransactionOptions.IReadWrite|null); + + /** TransactionOptions readOnly */ + readOnly?: (google.datastore.v1.TransactionOptions.IReadOnly|null); + } + + /** Represents a TransactionOptions. */ + class TransactionOptions implements ITransactionOptions { + + /** + * Constructs a new TransactionOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.ITransactionOptions); + + /** TransactionOptions readWrite. */ + public readWrite?: (google.datastore.v1.TransactionOptions.IReadWrite|null); + + /** TransactionOptions readOnly. */ + public readOnly?: (google.datastore.v1.TransactionOptions.IReadOnly|null); + + /** TransactionOptions mode. */ + public mode?: ("readWrite"|"readOnly"); + + /** + * Creates a new TransactionOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns TransactionOptions instance + */ + public static create(properties?: google.datastore.v1.ITransactionOptions): google.datastore.v1.TransactionOptions; + + /** + * Encodes the specified TransactionOptions message. Does not implicitly {@link google.datastore.v1.TransactionOptions.verify|verify} messages. + * @param message TransactionOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.ITransactionOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified TransactionOptions message, length delimited. Does not implicitly {@link google.datastore.v1.TransactionOptions.verify|verify} messages. + * @param message TransactionOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.ITransactionOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.TransactionOptions; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.TransactionOptions; + + /** + * Verifies a TransactionOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns TransactionOptions + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.TransactionOptions; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @param message TransactionOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.TransactionOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this TransactionOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for TransactionOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace TransactionOptions { + + /** Properties of a ReadWrite. */ + interface IReadWrite { + + /** ReadWrite previousTransaction */ + previousTransaction?: (Uint8Array|Buffer|string|null); + } + + /** Represents a ReadWrite. */ + class ReadWrite implements IReadWrite { + + /** + * Constructs a new ReadWrite. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.TransactionOptions.IReadWrite); + + /** ReadWrite previousTransaction. */ + public previousTransaction: (Uint8Array|Buffer|string); + + /** + * Creates a new ReadWrite instance using the specified properties. + * @param [properties] Properties to set + * @returns ReadWrite instance + */ + public static create(properties?: google.datastore.v1.TransactionOptions.IReadWrite): google.datastore.v1.TransactionOptions.ReadWrite; + + /** + * Encodes the specified ReadWrite message. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadWrite.verify|verify} messages. + * @param message ReadWrite message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.TransactionOptions.IReadWrite, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReadWrite message, length delimited. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadWrite.verify|verify} messages. + * @param message ReadWrite message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.TransactionOptions.IReadWrite, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReadWrite message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.TransactionOptions.ReadWrite; + + /** + * Decodes a ReadWrite message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.TransactionOptions.ReadWrite; + + /** + * Verifies a ReadWrite message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadWrite + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.TransactionOptions.ReadWrite; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @param message ReadWrite + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.TransactionOptions.ReadWrite, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadWrite to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReadWrite + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReadOnly. */ + interface IReadOnly { + + /** ReadOnly readTime */ + readTime?: (google.protobuf.ITimestamp|null); + } + + /** Represents a ReadOnly. */ + class ReadOnly implements IReadOnly { + + /** + * Constructs a new ReadOnly. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.TransactionOptions.IReadOnly); + + /** ReadOnly readTime. */ + public readTime?: (google.protobuf.ITimestamp|null); + + /** + * Creates a new ReadOnly instance using the specified properties. + * @param [properties] Properties to set + * @returns ReadOnly instance + */ + public static create(properties?: google.datastore.v1.TransactionOptions.IReadOnly): google.datastore.v1.TransactionOptions.ReadOnly; + + /** + * Encodes the specified ReadOnly message. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadOnly.verify|verify} messages. + * @param message ReadOnly message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.TransactionOptions.IReadOnly, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReadOnly message, length delimited. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadOnly.verify|verify} messages. + * @param message ReadOnly message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.TransactionOptions.IReadOnly, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReadOnly message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.TransactionOptions.ReadOnly; + + /** + * Decodes a ReadOnly message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.TransactionOptions.ReadOnly; + + /** + * Verifies a ReadOnly message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReadOnly + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.TransactionOptions.ReadOnly; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @param message ReadOnly + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.TransactionOptions.ReadOnly, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReadOnly to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReadOnly + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an ExplainOptions. */ + interface IExplainOptions { + + /** ExplainOptions analyze */ + analyze?: (boolean|null); + } + + /** Represents an ExplainOptions. */ + class ExplainOptions implements IExplainOptions { + + /** + * Constructs a new ExplainOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IExplainOptions); + + /** ExplainOptions analyze. */ + public analyze: boolean; + + /** + * Creates a new ExplainOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns ExplainOptions instance + */ + public static create(properties?: google.datastore.v1.IExplainOptions): google.datastore.v1.ExplainOptions; + + /** + * Encodes the specified ExplainOptions message. Does not implicitly {@link google.datastore.v1.ExplainOptions.verify|verify} messages. + * @param message ExplainOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IExplainOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExplainOptions message, length delimited. Does not implicitly {@link google.datastore.v1.ExplainOptions.verify|verify} messages. + * @param message ExplainOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IExplainOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExplainOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExplainOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.ExplainOptions; + + /** + * Decodes an ExplainOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExplainOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.ExplainOptions; + + /** + * Verifies an ExplainOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExplainOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExplainOptions + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.ExplainOptions; + + /** + * Creates a plain object from an ExplainOptions message. Also converts values to other types if specified. + * @param message ExplainOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.ExplainOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExplainOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExplainOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExplainMetrics. */ + interface IExplainMetrics { + + /** ExplainMetrics planSummary */ + planSummary?: (google.datastore.v1.IPlanSummary|null); + + /** ExplainMetrics executionStats */ + executionStats?: (google.datastore.v1.IExecutionStats|null); + } + + /** Represents an ExplainMetrics. */ + class ExplainMetrics implements IExplainMetrics { + + /** + * Constructs a new ExplainMetrics. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IExplainMetrics); + + /** ExplainMetrics planSummary. */ + public planSummary?: (google.datastore.v1.IPlanSummary|null); + + /** ExplainMetrics executionStats. */ + public executionStats?: (google.datastore.v1.IExecutionStats|null); + + /** + * Creates a new ExplainMetrics instance using the specified properties. + * @param [properties] Properties to set + * @returns ExplainMetrics instance + */ + public static create(properties?: google.datastore.v1.IExplainMetrics): google.datastore.v1.ExplainMetrics; + + /** + * Encodes the specified ExplainMetrics message. Does not implicitly {@link google.datastore.v1.ExplainMetrics.verify|verify} messages. + * @param message ExplainMetrics message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IExplainMetrics, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExplainMetrics message, length delimited. Does not implicitly {@link google.datastore.v1.ExplainMetrics.verify|verify} messages. + * @param message ExplainMetrics message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IExplainMetrics, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExplainMetrics message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExplainMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.ExplainMetrics; + + /** + * Decodes an ExplainMetrics message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExplainMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.ExplainMetrics; + + /** + * Verifies an ExplainMetrics message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExplainMetrics message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExplainMetrics + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.ExplainMetrics; + + /** + * Creates a plain object from an ExplainMetrics message. Also converts values to other types if specified. + * @param message ExplainMetrics + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.ExplainMetrics, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExplainMetrics to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExplainMetrics + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PlanSummary. */ + interface IPlanSummary { + + /** PlanSummary indexesUsed */ + indexesUsed?: (google.protobuf.IStruct[]|null); + } + + /** Represents a PlanSummary. */ + class PlanSummary implements IPlanSummary { + + /** + * Constructs a new PlanSummary. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IPlanSummary); + + /** PlanSummary indexesUsed. */ + public indexesUsed: google.protobuf.IStruct[]; + + /** + * Creates a new PlanSummary instance using the specified properties. + * @param [properties] Properties to set + * @returns PlanSummary instance + */ + public static create(properties?: google.datastore.v1.IPlanSummary): google.datastore.v1.PlanSummary; + + /** + * Encodes the specified PlanSummary message. Does not implicitly {@link google.datastore.v1.PlanSummary.verify|verify} messages. + * @param message PlanSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IPlanSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PlanSummary message, length delimited. Does not implicitly {@link google.datastore.v1.PlanSummary.verify|verify} messages. + * @param message PlanSummary message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IPlanSummary, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PlanSummary message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PlanSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.PlanSummary; + + /** + * Decodes a PlanSummary message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PlanSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.PlanSummary; + + /** + * Verifies a PlanSummary message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PlanSummary message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PlanSummary + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.PlanSummary; + + /** + * Creates a plain object from a PlanSummary message. Also converts values to other types if specified. + * @param message PlanSummary + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.PlanSummary, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PlanSummary to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PlanSummary + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an ExecutionStats. */ + interface IExecutionStats { + + /** ExecutionStats resultsReturned */ + resultsReturned?: (number|Long|string|null); + + /** ExecutionStats executionDuration */ + executionDuration?: (google.protobuf.IDuration|null); + + /** ExecutionStats readOperations */ + readOperations?: (number|Long|string|null); + + /** ExecutionStats debugStats */ + debugStats?: (google.protobuf.IStruct|null); + } + + /** Represents an ExecutionStats. */ + class ExecutionStats implements IExecutionStats { + + /** + * Constructs a new ExecutionStats. + * @param [properties] Properties to set + */ + constructor(properties?: google.datastore.v1.IExecutionStats); + + /** ExecutionStats resultsReturned. */ + public resultsReturned: (number|Long|string); + + /** ExecutionStats executionDuration. */ + public executionDuration?: (google.protobuf.IDuration|null); + + /** ExecutionStats readOperations. */ + public readOperations: (number|Long|string); + + /** ExecutionStats debugStats. */ + public debugStats?: (google.protobuf.IStruct|null); + + /** + * Creates a new ExecutionStats instance using the specified properties. + * @param [properties] Properties to set + * @returns ExecutionStats instance + */ + public static create(properties?: google.datastore.v1.IExecutionStats): google.datastore.v1.ExecutionStats; + + /** + * Encodes the specified ExecutionStats message. Does not implicitly {@link google.datastore.v1.ExecutionStats.verify|verify} messages. + * @param message ExecutionStats message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.datastore.v1.IExecutionStats, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExecutionStats message, length delimited. Does not implicitly {@link google.datastore.v1.ExecutionStats.verify|verify} messages. + * @param message ExecutionStats message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.datastore.v1.IExecutionStats, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExecutionStats message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExecutionStats + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.datastore.v1.ExecutionStats; + + /** + * Decodes an ExecutionStats message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExecutionStats + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.datastore.v1.ExecutionStats; + + /** + * Verifies an ExecutionStats message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExecutionStats message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExecutionStats + */ + public static fromObject(object: { [k: string]: any }): google.datastore.v1.ExecutionStats; + + /** + * Creates a plain object from an ExecutionStats message. Also converts values to other types if specified. + * @param message ExecutionStats + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.datastore.v1.ExecutionStats, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExecutionStats to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExecutionStats + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + } + + /** Namespace api. */ + namespace api { + + /** Properties of a Http. */ + interface IHttp { + + /** Http rules */ + rules?: (google.api.IHttpRule[]|null); + + /** Http fullyDecodeReservedExpansion */ + fullyDecodeReservedExpansion?: (boolean|null); + } + + /** Represents a Http. */ + class Http implements IHttp { + + /** + * Constructs a new Http. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttp); + + /** Http rules. */ + public rules: google.api.IHttpRule[]; + + /** Http fullyDecodeReservedExpansion. */ + public fullyDecodeReservedExpansion: boolean; + + /** + * Creates a new Http instance using the specified properties. + * @param [properties] Properties to set + * @returns Http instance + */ + public static create(properties?: google.api.IHttp): google.api.Http; + + /** + * Encodes the specified Http message. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @param message Http message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IHttp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Http message, length delimited. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @param message Http message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IHttp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Http message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.Http; + + /** + * Decodes a Http message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.Http; + + /** + * Verifies a Http message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Http + */ + public static fromObject(object: { [k: string]: any }): google.api.Http; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @param message Http + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Http, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Http to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Http + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a HttpRule. */ + interface IHttpRule { + + /** HttpRule selector */ + selector?: (string|null); + + /** HttpRule get */ + get?: (string|null); + + /** HttpRule put */ + put?: (string|null); + + /** HttpRule post */ + post?: (string|null); + + /** HttpRule delete */ + "delete"?: (string|null); + + /** HttpRule patch */ + patch?: (string|null); + + /** HttpRule custom */ + custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule body */ + body?: (string|null); + + /** HttpRule responseBody */ + responseBody?: (string|null); + + /** HttpRule additionalBindings */ + additionalBindings?: (google.api.IHttpRule[]|null); + } + + /** Represents a HttpRule. */ + class HttpRule implements IHttpRule { + + /** + * Constructs a new HttpRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IHttpRule); + + /** HttpRule selector. */ + public selector: string; + + /** HttpRule get. */ + public get?: (string|null); + + /** HttpRule put. */ + public put?: (string|null); + + /** HttpRule post. */ + public post?: (string|null); + + /** HttpRule delete. */ + public delete?: (string|null); + + /** HttpRule patch. */ + public patch?: (string|null); + + /** HttpRule custom. */ + public custom?: (google.api.ICustomHttpPattern|null); + + /** HttpRule body. */ + public body: string; + + /** HttpRule responseBody. */ + public responseBody: string; + + /** HttpRule additionalBindings. */ + public additionalBindings: google.api.IHttpRule[]; + + /** HttpRule pattern. */ + public pattern?: ("get"|"put"|"post"|"delete"|"patch"|"custom"); + + /** + * Creates a new HttpRule instance using the specified properties. + * @param [properties] Properties to set + * @returns HttpRule instance + */ + public static create(properties?: google.api.IHttpRule): google.api.HttpRule; + + /** + * Encodes the specified HttpRule message. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @param message HttpRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IHttpRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified HttpRule message, length delimited. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @param message HttpRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IHttpRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a HttpRule message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.HttpRule; + + /** + * Decodes a HttpRule message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.HttpRule; + + /** + * Verifies a HttpRule message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns HttpRule + */ + public static fromObject(object: { [k: string]: any }): google.api.HttpRule; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @param message HttpRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.HttpRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this HttpRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for HttpRule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CustomHttpPattern. */ + interface ICustomHttpPattern { + + /** CustomHttpPattern kind */ + kind?: (string|null); + + /** CustomHttpPattern path */ + path?: (string|null); + } + + /** Represents a CustomHttpPattern. */ + class CustomHttpPattern implements ICustomHttpPattern { + + /** + * Constructs a new CustomHttpPattern. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICustomHttpPattern); + + /** CustomHttpPattern kind. */ + public kind: string; + + /** CustomHttpPattern path. */ + public path: string; + + /** + * Creates a new CustomHttpPattern instance using the specified properties. + * @param [properties] Properties to set + * @returns CustomHttpPattern instance + */ + public static create(properties?: google.api.ICustomHttpPattern): google.api.CustomHttpPattern; + + /** + * Encodes the specified CustomHttpPattern message. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @param message CustomHttpPattern message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ICustomHttpPattern, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CustomHttpPattern message, length delimited. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @param message CustomHttpPattern message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ICustomHttpPattern, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.CustomHttpPattern; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.CustomHttpPattern; + + /** + * Verifies a CustomHttpPattern message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CustomHttpPattern + */ + public static fromObject(object: { [k: string]: any }): google.api.CustomHttpPattern; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @param message CustomHttpPattern + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CustomHttpPattern, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CustomHttpPattern to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CustomHttpPattern + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CommonLanguageSettings. */ + interface ICommonLanguageSettings { + + /** CommonLanguageSettings referenceDocsUri */ + referenceDocsUri?: (string|null); + + /** CommonLanguageSettings destinations */ + destinations?: (google.api.ClientLibraryDestination[]|null); + + /** CommonLanguageSettings selectiveGapicGeneration */ + selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + } + + /** Represents a CommonLanguageSettings. */ + class CommonLanguageSettings implements ICommonLanguageSettings { + + /** + * Constructs a new CommonLanguageSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICommonLanguageSettings); + + /** CommonLanguageSettings referenceDocsUri. */ + public referenceDocsUri: string; + + /** CommonLanguageSettings destinations. */ + public destinations: google.api.ClientLibraryDestination[]; + + /** CommonLanguageSettings selectiveGapicGeneration. */ + public selectiveGapicGeneration?: (google.api.ISelectiveGapicGeneration|null); + + /** + * Creates a new CommonLanguageSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns CommonLanguageSettings instance + */ + public static create(properties?: google.api.ICommonLanguageSettings): google.api.CommonLanguageSettings; + + /** + * Encodes the specified CommonLanguageSettings message. Does not implicitly {@link google.api.CommonLanguageSettings.verify|verify} messages. + * @param message CommonLanguageSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ICommonLanguageSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CommonLanguageSettings message, length delimited. Does not implicitly {@link google.api.CommonLanguageSettings.verify|verify} messages. + * @param message CommonLanguageSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ICommonLanguageSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CommonLanguageSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CommonLanguageSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.CommonLanguageSettings; + + /** + * Decodes a CommonLanguageSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CommonLanguageSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.CommonLanguageSettings; + + /** + * Verifies a CommonLanguageSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CommonLanguageSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CommonLanguageSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.CommonLanguageSettings; + + /** + * Creates a plain object from a CommonLanguageSettings message. Also converts values to other types if specified. + * @param message CommonLanguageSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CommonLanguageSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CommonLanguageSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CommonLanguageSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ClientLibrarySettings. */ + interface IClientLibrarySettings { + + /** ClientLibrarySettings version */ + version?: (string|null); + + /** ClientLibrarySettings launchStage */ + launchStage?: (google.api.LaunchStage|keyof typeof google.api.LaunchStage|null); + + /** ClientLibrarySettings restNumericEnums */ + restNumericEnums?: (boolean|null); + + /** ClientLibrarySettings javaSettings */ + javaSettings?: (google.api.IJavaSettings|null); + + /** ClientLibrarySettings cppSettings */ + cppSettings?: (google.api.ICppSettings|null); + + /** ClientLibrarySettings phpSettings */ + phpSettings?: (google.api.IPhpSettings|null); + + /** ClientLibrarySettings pythonSettings */ + pythonSettings?: (google.api.IPythonSettings|null); + + /** ClientLibrarySettings nodeSettings */ + nodeSettings?: (google.api.INodeSettings|null); + + /** ClientLibrarySettings dotnetSettings */ + dotnetSettings?: (google.api.IDotnetSettings|null); + + /** ClientLibrarySettings rubySettings */ + rubySettings?: (google.api.IRubySettings|null); + + /** ClientLibrarySettings goSettings */ + goSettings?: (google.api.IGoSettings|null); + } + + /** Represents a ClientLibrarySettings. */ + class ClientLibrarySettings implements IClientLibrarySettings { + + /** + * Constructs a new ClientLibrarySettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IClientLibrarySettings); + + /** ClientLibrarySettings version. */ + public version: string; + + /** ClientLibrarySettings launchStage. */ + public launchStage: (google.api.LaunchStage|keyof typeof google.api.LaunchStage); + + /** ClientLibrarySettings restNumericEnums. */ + public restNumericEnums: boolean; + + /** ClientLibrarySettings javaSettings. */ + public javaSettings?: (google.api.IJavaSettings|null); + + /** ClientLibrarySettings cppSettings. */ + public cppSettings?: (google.api.ICppSettings|null); + + /** ClientLibrarySettings phpSettings. */ + public phpSettings?: (google.api.IPhpSettings|null); + + /** ClientLibrarySettings pythonSettings. */ + public pythonSettings?: (google.api.IPythonSettings|null); + + /** ClientLibrarySettings nodeSettings. */ + public nodeSettings?: (google.api.INodeSettings|null); + + /** ClientLibrarySettings dotnetSettings. */ + public dotnetSettings?: (google.api.IDotnetSettings|null); + + /** ClientLibrarySettings rubySettings. */ + public rubySettings?: (google.api.IRubySettings|null); + + /** ClientLibrarySettings goSettings. */ + public goSettings?: (google.api.IGoSettings|null); + + /** + * Creates a new ClientLibrarySettings instance using the specified properties. + * @param [properties] Properties to set + * @returns ClientLibrarySettings instance + */ + public static create(properties?: google.api.IClientLibrarySettings): google.api.ClientLibrarySettings; + + /** + * Encodes the specified ClientLibrarySettings message. Does not implicitly {@link google.api.ClientLibrarySettings.verify|verify} messages. + * @param message ClientLibrarySettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IClientLibrarySettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ClientLibrarySettings message, length delimited. Does not implicitly {@link google.api.ClientLibrarySettings.verify|verify} messages. + * @param message ClientLibrarySettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IClientLibrarySettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ClientLibrarySettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ClientLibrarySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.ClientLibrarySettings; + + /** + * Decodes a ClientLibrarySettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ClientLibrarySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.ClientLibrarySettings; + + /** + * Verifies a ClientLibrarySettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ClientLibrarySettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ClientLibrarySettings + */ + public static fromObject(object: { [k: string]: any }): google.api.ClientLibrarySettings; + + /** + * Creates a plain object from a ClientLibrarySettings message. Also converts values to other types if specified. + * @param message ClientLibrarySettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.ClientLibrarySettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ClientLibrarySettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ClientLibrarySettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Publishing. */ + interface IPublishing { + + /** Publishing methodSettings */ + methodSettings?: (google.api.IMethodSettings[]|null); + + /** Publishing newIssueUri */ + newIssueUri?: (string|null); + + /** Publishing documentationUri */ + documentationUri?: (string|null); + + /** Publishing apiShortName */ + apiShortName?: (string|null); + + /** Publishing githubLabel */ + githubLabel?: (string|null); + + /** Publishing codeownerGithubTeams */ + codeownerGithubTeams?: (string[]|null); + + /** Publishing docTagPrefix */ + docTagPrefix?: (string|null); + + /** Publishing organization */ + organization?: (google.api.ClientLibraryOrganization|keyof typeof google.api.ClientLibraryOrganization|null); + + /** Publishing librarySettings */ + librarySettings?: (google.api.IClientLibrarySettings[]|null); + + /** Publishing protoReferenceDocumentationUri */ + protoReferenceDocumentationUri?: (string|null); + + /** Publishing restReferenceDocumentationUri */ + restReferenceDocumentationUri?: (string|null); + } + + /** Represents a Publishing. */ + class Publishing implements IPublishing { + + /** + * Constructs a new Publishing. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IPublishing); + + /** Publishing methodSettings. */ + public methodSettings: google.api.IMethodSettings[]; + + /** Publishing newIssueUri. */ + public newIssueUri: string; + + /** Publishing documentationUri. */ + public documentationUri: string; + + /** Publishing apiShortName. */ + public apiShortName: string; + + /** Publishing githubLabel. */ + public githubLabel: string; + + /** Publishing codeownerGithubTeams. */ + public codeownerGithubTeams: string[]; + + /** Publishing docTagPrefix. */ + public docTagPrefix: string; + + /** Publishing organization. */ + public organization: (google.api.ClientLibraryOrganization|keyof typeof google.api.ClientLibraryOrganization); + + /** Publishing librarySettings. */ + public librarySettings: google.api.IClientLibrarySettings[]; + + /** Publishing protoReferenceDocumentationUri. */ + public protoReferenceDocumentationUri: string; + + /** Publishing restReferenceDocumentationUri. */ + public restReferenceDocumentationUri: string; + + /** + * Creates a new Publishing instance using the specified properties. + * @param [properties] Properties to set + * @returns Publishing instance + */ + public static create(properties?: google.api.IPublishing): google.api.Publishing; + + /** + * Encodes the specified Publishing message. Does not implicitly {@link google.api.Publishing.verify|verify} messages. + * @param message Publishing message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IPublishing, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Publishing message, length delimited. Does not implicitly {@link google.api.Publishing.verify|verify} messages. + * @param message Publishing message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IPublishing, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Publishing message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Publishing + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.Publishing; + + /** + * Decodes a Publishing message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Publishing + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.Publishing; + + /** + * Verifies a Publishing message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Publishing message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Publishing + */ + public static fromObject(object: { [k: string]: any }): google.api.Publishing; + + /** + * Creates a plain object from a Publishing message. Also converts values to other types if specified. + * @param message Publishing + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.Publishing, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Publishing to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Publishing + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a JavaSettings. */ + interface IJavaSettings { + + /** JavaSettings libraryPackage */ + libraryPackage?: (string|null); + + /** JavaSettings serviceClassNames */ + serviceClassNames?: ({ [k: string]: string }|null); + + /** JavaSettings common */ + common?: (google.api.ICommonLanguageSettings|null); + } + + /** Represents a JavaSettings. */ + class JavaSettings implements IJavaSettings { + + /** + * Constructs a new JavaSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IJavaSettings); + + /** JavaSettings libraryPackage. */ + public libraryPackage: string; + + /** JavaSettings serviceClassNames. */ + public serviceClassNames: { [k: string]: string }; + + /** JavaSettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** + * Creates a new JavaSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns JavaSettings instance + */ + public static create(properties?: google.api.IJavaSettings): google.api.JavaSettings; + + /** + * Encodes the specified JavaSettings message. Does not implicitly {@link google.api.JavaSettings.verify|verify} messages. + * @param message JavaSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IJavaSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified JavaSettings message, length delimited. Does not implicitly {@link google.api.JavaSettings.verify|verify} messages. + * @param message JavaSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IJavaSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a JavaSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns JavaSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.JavaSettings; + + /** + * Decodes a JavaSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns JavaSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.JavaSettings; + + /** + * Verifies a JavaSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a JavaSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns JavaSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.JavaSettings; + + /** + * Creates a plain object from a JavaSettings message. Also converts values to other types if specified. + * @param message JavaSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.JavaSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this JavaSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for JavaSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CppSettings. */ + interface ICppSettings { + + /** CppSettings common */ + common?: (google.api.ICommonLanguageSettings|null); + } + + /** Represents a CppSettings. */ + class CppSettings implements ICppSettings { + + /** + * Constructs a new CppSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ICppSettings); + + /** CppSettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** + * Creates a new CppSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns CppSettings instance + */ + public static create(properties?: google.api.ICppSettings): google.api.CppSettings; + + /** + * Encodes the specified CppSettings message. Does not implicitly {@link google.api.CppSettings.verify|verify} messages. + * @param message CppSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ICppSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CppSettings message, length delimited. Does not implicitly {@link google.api.CppSettings.verify|verify} messages. + * @param message CppSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ICppSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CppSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CppSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.CppSettings; + + /** + * Decodes a CppSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CppSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.CppSettings; + + /** + * Verifies a CppSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CppSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CppSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.CppSettings; + + /** + * Creates a plain object from a CppSettings message. Also converts values to other types if specified. + * @param message CppSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.CppSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CppSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CppSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PhpSettings. */ + interface IPhpSettings { + + /** PhpSettings common */ + common?: (google.api.ICommonLanguageSettings|null); + } + + /** Represents a PhpSettings. */ + class PhpSettings implements IPhpSettings { + + /** + * Constructs a new PhpSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IPhpSettings); + + /** PhpSettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** + * Creates a new PhpSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns PhpSettings instance + */ + public static create(properties?: google.api.IPhpSettings): google.api.PhpSettings; + + /** + * Encodes the specified PhpSettings message. Does not implicitly {@link google.api.PhpSettings.verify|verify} messages. + * @param message PhpSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IPhpSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PhpSettings message, length delimited. Does not implicitly {@link google.api.PhpSettings.verify|verify} messages. + * @param message PhpSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IPhpSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PhpSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PhpSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.PhpSettings; + + /** + * Decodes a PhpSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PhpSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.PhpSettings; + + /** + * Verifies a PhpSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PhpSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PhpSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.PhpSettings; + + /** + * Creates a plain object from a PhpSettings message. Also converts values to other types if specified. + * @param message PhpSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PhpSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PhpSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PhpSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a PythonSettings. */ + interface IPythonSettings { + + /** PythonSettings common */ + common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures */ + experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + } + + /** Represents a PythonSettings. */ + class PythonSettings implements IPythonSettings { + + /** + * Constructs a new PythonSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IPythonSettings); + + /** PythonSettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** PythonSettings experimentalFeatures. */ + public experimentalFeatures?: (google.api.PythonSettings.IExperimentalFeatures|null); + + /** + * Creates a new PythonSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns PythonSettings instance + */ + public static create(properties?: google.api.IPythonSettings): google.api.PythonSettings; + + /** + * Encodes the specified PythonSettings message. Does not implicitly {@link google.api.PythonSettings.verify|verify} messages. + * @param message PythonSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IPythonSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PythonSettings message, length delimited. Does not implicitly {@link google.api.PythonSettings.verify|verify} messages. + * @param message PythonSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IPythonSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PythonSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PythonSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.PythonSettings; + + /** + * Decodes a PythonSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PythonSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.PythonSettings; + + /** + * Verifies a PythonSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a PythonSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PythonSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings; + + /** + * Creates a plain object from a PythonSettings message. Also converts values to other types if specified. + * @param message PythonSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PythonSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for PythonSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace PythonSettings { + + /** Properties of an ExperimentalFeatures. */ + interface IExperimentalFeatures { + + /** ExperimentalFeatures restAsyncIoEnabled */ + restAsyncIoEnabled?: (boolean|null); + + /** ExperimentalFeatures protobufPythonicTypesEnabled */ + protobufPythonicTypesEnabled?: (boolean|null); + + /** ExperimentalFeatures unversionedPackageDisabled */ + unversionedPackageDisabled?: (boolean|null); + } + + /** Represents an ExperimentalFeatures. */ + class ExperimentalFeatures implements IExperimentalFeatures { + + /** + * Constructs a new ExperimentalFeatures. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.PythonSettings.IExperimentalFeatures); + + /** ExperimentalFeatures restAsyncIoEnabled. */ + public restAsyncIoEnabled: boolean; + + /** ExperimentalFeatures protobufPythonicTypesEnabled. */ + public protobufPythonicTypesEnabled: boolean; + + /** ExperimentalFeatures unversionedPackageDisabled. */ + public unversionedPackageDisabled: boolean; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @param [properties] Properties to set + * @returns ExperimentalFeatures instance + */ + public static create(properties?: google.api.PythonSettings.IExperimentalFeatures): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @param message ExperimentalFeatures message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.PythonSettings.IExperimentalFeatures, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Verifies an ExperimentalFeatures message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExperimentalFeatures + */ + public static fromObject(object: { [k: string]: any }): google.api.PythonSettings.ExperimentalFeatures; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @param message ExperimentalFeatures + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.PythonSettings.ExperimentalFeatures, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExperimentalFeatures + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a NodeSettings. */ + interface INodeSettings { + + /** NodeSettings common */ + common?: (google.api.ICommonLanguageSettings|null); + } + + /** Represents a NodeSettings. */ + class NodeSettings implements INodeSettings { + + /** + * Constructs a new NodeSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.INodeSettings); + + /** NodeSettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** + * Creates a new NodeSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns NodeSettings instance + */ + public static create(properties?: google.api.INodeSettings): google.api.NodeSettings; + + /** + * Encodes the specified NodeSettings message. Does not implicitly {@link google.api.NodeSettings.verify|verify} messages. + * @param message NodeSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.INodeSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified NodeSettings message, length delimited. Does not implicitly {@link google.api.NodeSettings.verify|verify} messages. + * @param message NodeSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.INodeSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a NodeSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns NodeSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.NodeSettings; + + /** + * Decodes a NodeSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns NodeSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.NodeSettings; + + /** + * Verifies a NodeSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a NodeSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NodeSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.NodeSettings; + + /** + * Creates a plain object from a NodeSettings message. Also converts values to other types if specified. + * @param message NodeSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.NodeSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NodeSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for NodeSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DotnetSettings. */ + interface IDotnetSettings { + + /** DotnetSettings common */ + common?: (google.api.ICommonLanguageSettings|null); + + /** DotnetSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); + + /** DotnetSettings renamedResources */ + renamedResources?: ({ [k: string]: string }|null); + + /** DotnetSettings ignoredResources */ + ignoredResources?: (string[]|null); + + /** DotnetSettings forcedNamespaceAliases */ + forcedNamespaceAliases?: (string[]|null); + + /** DotnetSettings handwrittenSignatures */ + handwrittenSignatures?: (string[]|null); + } + + /** Represents a DotnetSettings. */ + class DotnetSettings implements IDotnetSettings { + + /** + * Constructs a new DotnetSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IDotnetSettings); + + /** DotnetSettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** DotnetSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + + /** DotnetSettings renamedResources. */ + public renamedResources: { [k: string]: string }; + + /** DotnetSettings ignoredResources. */ + public ignoredResources: string[]; + + /** DotnetSettings forcedNamespaceAliases. */ + public forcedNamespaceAliases: string[]; + + /** DotnetSettings handwrittenSignatures. */ + public handwrittenSignatures: string[]; + + /** + * Creates a new DotnetSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns DotnetSettings instance + */ + public static create(properties?: google.api.IDotnetSettings): google.api.DotnetSettings; + + /** + * Encodes the specified DotnetSettings message. Does not implicitly {@link google.api.DotnetSettings.verify|verify} messages. + * @param message DotnetSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IDotnetSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DotnetSettings message, length delimited. Does not implicitly {@link google.api.DotnetSettings.verify|verify} messages. + * @param message DotnetSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IDotnetSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DotnetSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DotnetSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.DotnetSettings; + + /** + * Decodes a DotnetSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DotnetSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.DotnetSettings; + + /** + * Verifies a DotnetSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DotnetSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DotnetSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.DotnetSettings; + + /** + * Creates a plain object from a DotnetSettings message. Also converts values to other types if specified. + * @param message DotnetSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.DotnetSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DotnetSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DotnetSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RubySettings. */ + interface IRubySettings { + + /** RubySettings common */ + common?: (google.api.ICommonLanguageSettings|null); + } + + /** Represents a RubySettings. */ + class RubySettings implements IRubySettings { + + /** + * Constructs a new RubySettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IRubySettings); + + /** RubySettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** + * Creates a new RubySettings instance using the specified properties. + * @param [properties] Properties to set + * @returns RubySettings instance + */ + public static create(properties?: google.api.IRubySettings): google.api.RubySettings; + + /** + * Encodes the specified RubySettings message. Does not implicitly {@link google.api.RubySettings.verify|verify} messages. + * @param message RubySettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IRubySettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RubySettings message, length delimited. Does not implicitly {@link google.api.RubySettings.verify|verify} messages. + * @param message RubySettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IRubySettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RubySettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RubySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.RubySettings; + + /** + * Decodes a RubySettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RubySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.RubySettings; + + /** + * Verifies a RubySettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RubySettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RubySettings + */ + public static fromObject(object: { [k: string]: any }): google.api.RubySettings; + + /** + * Creates a plain object from a RubySettings message. Also converts values to other types if specified. + * @param message RubySettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.RubySettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RubySettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RubySettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GoSettings. */ + interface IGoSettings { + + /** GoSettings common */ + common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices */ + renamedServices?: ({ [k: string]: string }|null); + } + + /** Represents a GoSettings. */ + class GoSettings implements IGoSettings { + + /** + * Constructs a new GoSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IGoSettings); + + /** GoSettings common. */ + public common?: (google.api.ICommonLanguageSettings|null); + + /** GoSettings renamedServices. */ + public renamedServices: { [k: string]: string }; + + /** + * Creates a new GoSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns GoSettings instance + */ + public static create(properties?: google.api.IGoSettings): google.api.GoSettings; + + /** + * Encodes the specified GoSettings message. Does not implicitly {@link google.api.GoSettings.verify|verify} messages. + * @param message GoSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IGoSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GoSettings message, length delimited. Does not implicitly {@link google.api.GoSettings.verify|verify} messages. + * @param message GoSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IGoSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GoSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GoSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.GoSettings; + + /** + * Decodes a GoSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GoSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.GoSettings; + + /** + * Verifies a GoSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GoSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GoSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.GoSettings; + + /** + * Creates a plain object from a GoSettings message. Also converts values to other types if specified. + * @param message GoSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.GoSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GoSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GoSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MethodSettings. */ + interface IMethodSettings { + + /** MethodSettings selector */ + selector?: (string|null); + + /** MethodSettings longRunning */ + longRunning?: (google.api.MethodSettings.ILongRunning|null); + + /** MethodSettings autoPopulatedFields */ + autoPopulatedFields?: (string[]|null); + } + + /** Represents a MethodSettings. */ + class MethodSettings implements IMethodSettings { + + /** + * Constructs a new MethodSettings. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IMethodSettings); + + /** MethodSettings selector. */ + public selector: string; + + /** MethodSettings longRunning. */ + public longRunning?: (google.api.MethodSettings.ILongRunning|null); + + /** MethodSettings autoPopulatedFields. */ + public autoPopulatedFields: string[]; + + /** + * Creates a new MethodSettings instance using the specified properties. + * @param [properties] Properties to set + * @returns MethodSettings instance + */ + public static create(properties?: google.api.IMethodSettings): google.api.MethodSettings; + + /** + * Encodes the specified MethodSettings message. Does not implicitly {@link google.api.MethodSettings.verify|verify} messages. + * @param message MethodSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IMethodSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MethodSettings message, length delimited. Does not implicitly {@link google.api.MethodSettings.verify|verify} messages. + * @param message MethodSettings message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IMethodSettings, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MethodSettings message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MethodSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.MethodSettings; + + /** + * Decodes a MethodSettings message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MethodSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.MethodSettings; + + /** + * Verifies a MethodSettings message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MethodSettings message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodSettings + */ + public static fromObject(object: { [k: string]: any }): google.api.MethodSettings; + + /** + * Creates a plain object from a MethodSettings message. Also converts values to other types if specified. + * @param message MethodSettings + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.MethodSettings, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodSettings to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MethodSettings + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace MethodSettings { + + /** Properties of a LongRunning. */ + interface ILongRunning { + + /** LongRunning initialPollDelay */ + initialPollDelay?: (google.protobuf.IDuration|null); + + /** LongRunning pollDelayMultiplier */ + pollDelayMultiplier?: (number|null); + + /** LongRunning maxPollDelay */ + maxPollDelay?: (google.protobuf.IDuration|null); + + /** LongRunning totalPollTimeout */ + totalPollTimeout?: (google.protobuf.IDuration|null); + } + + /** Represents a LongRunning. */ + class LongRunning implements ILongRunning { + + /** + * Constructs a new LongRunning. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.MethodSettings.ILongRunning); + + /** LongRunning initialPollDelay. */ + public initialPollDelay?: (google.protobuf.IDuration|null); + + /** LongRunning pollDelayMultiplier. */ + public pollDelayMultiplier: number; + + /** LongRunning maxPollDelay. */ + public maxPollDelay?: (google.protobuf.IDuration|null); + + /** LongRunning totalPollTimeout. */ + public totalPollTimeout?: (google.protobuf.IDuration|null); + + /** + * Creates a new LongRunning instance using the specified properties. + * @param [properties] Properties to set + * @returns LongRunning instance + */ + public static create(properties?: google.api.MethodSettings.ILongRunning): google.api.MethodSettings.LongRunning; + + /** + * Encodes the specified LongRunning message. Does not implicitly {@link google.api.MethodSettings.LongRunning.verify|verify} messages. + * @param message LongRunning message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.MethodSettings.ILongRunning, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LongRunning message, length delimited. Does not implicitly {@link google.api.MethodSettings.LongRunning.verify|verify} messages. + * @param message LongRunning message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.MethodSettings.ILongRunning, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LongRunning message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LongRunning + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.MethodSettings.LongRunning; + + /** + * Decodes a LongRunning message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LongRunning + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.MethodSettings.LongRunning; + + /** + * Verifies a LongRunning message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LongRunning message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LongRunning + */ + public static fromObject(object: { [k: string]: any }): google.api.MethodSettings.LongRunning; + + /** + * Creates a plain object from a LongRunning message. Also converts values to other types if specified. + * @param message LongRunning + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.MethodSettings.LongRunning, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LongRunning to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LongRunning + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** ClientLibraryOrganization enum. */ + enum ClientLibraryOrganization { + CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED = 0, + CLOUD = 1, + ADS = 2, + PHOTOS = 3, + STREET_VIEW = 4, + SHOPPING = 5, + GEO = 6, + GENERATIVE_AI = 7 + } + + /** ClientLibraryDestination enum. */ + enum ClientLibraryDestination { + CLIENT_LIBRARY_DESTINATION_UNSPECIFIED = 0, + GITHUB = 10, + PACKAGE_MANAGER = 20 + } + + /** Properties of a SelectiveGapicGeneration. */ + interface ISelectiveGapicGeneration { + + /** SelectiveGapicGeneration methods */ + methods?: (string[]|null); + + /** SelectiveGapicGeneration generateOmittedAsInternal */ + generateOmittedAsInternal?: (boolean|null); + } + + /** Represents a SelectiveGapicGeneration. */ + class SelectiveGapicGeneration implements ISelectiveGapicGeneration { + + /** + * Constructs a new SelectiveGapicGeneration. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.ISelectiveGapicGeneration); + + /** SelectiveGapicGeneration methods. */ + public methods: string[]; + + /** SelectiveGapicGeneration generateOmittedAsInternal. */ + public generateOmittedAsInternal: boolean; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @param [properties] Properties to set + * @returns SelectiveGapicGeneration instance + */ + public static create(properties?: google.api.ISelectiveGapicGeneration): google.api.SelectiveGapicGeneration; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @param message SelectiveGapicGeneration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.ISelectiveGapicGeneration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.SelectiveGapicGeneration; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.SelectiveGapicGeneration; + + /** + * Verifies a SelectiveGapicGeneration message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SelectiveGapicGeneration + */ + public static fromObject(object: { [k: string]: any }): google.api.SelectiveGapicGeneration; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @param message SelectiveGapicGeneration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.SelectiveGapicGeneration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** LaunchStage enum. */ + enum LaunchStage { + LAUNCH_STAGE_UNSPECIFIED = 0, + UNIMPLEMENTED = 6, + PRELAUNCH = 7, + EARLY_ACCESS = 1, + ALPHA = 2, + BETA = 3, + GA = 4, + DEPRECATED = 5 + } + + /** FieldBehavior enum. */ + enum FieldBehavior { + FIELD_BEHAVIOR_UNSPECIFIED = 0, + OPTIONAL = 1, + REQUIRED = 2, + OUTPUT_ONLY = 3, + INPUT_ONLY = 4, + IMMUTABLE = 5, + UNORDERED_LIST = 6, + NON_EMPTY_DEFAULT = 7, + IDENTIFIER = 8 + } + + /** Properties of a RoutingRule. */ + interface IRoutingRule { + + /** RoutingRule routingParameters */ + routingParameters?: (google.api.IRoutingParameter[]|null); + } + + /** Represents a RoutingRule. */ + class RoutingRule implements IRoutingRule { + + /** + * Constructs a new RoutingRule. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IRoutingRule); + + /** RoutingRule routingParameters. */ + public routingParameters: google.api.IRoutingParameter[]; + + /** + * Creates a new RoutingRule instance using the specified properties. + * @param [properties] Properties to set + * @returns RoutingRule instance + */ + public static create(properties?: google.api.IRoutingRule): google.api.RoutingRule; + + /** + * Encodes the specified RoutingRule message. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @param message RoutingRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IRoutingRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RoutingRule message, length delimited. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @param message RoutingRule message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IRoutingRule, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RoutingRule message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.RoutingRule; + + /** + * Decodes a RoutingRule message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.RoutingRule; + + /** + * Verifies a RoutingRule message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RoutingRule message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RoutingRule + */ + public static fromObject(object: { [k: string]: any }): google.api.RoutingRule; + + /** + * Creates a plain object from a RoutingRule message. Also converts values to other types if specified. + * @param message RoutingRule + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.RoutingRule, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RoutingRule to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RoutingRule + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a RoutingParameter. */ + interface IRoutingParameter { + + /** RoutingParameter field */ + field?: (string|null); + + /** RoutingParameter pathTemplate */ + pathTemplate?: (string|null); + } + + /** Represents a RoutingParameter. */ + class RoutingParameter implements IRoutingParameter { + + /** + * Constructs a new RoutingParameter. + * @param [properties] Properties to set + */ + constructor(properties?: google.api.IRoutingParameter); + + /** RoutingParameter field. */ + public field: string; + + /** RoutingParameter pathTemplate. */ + public pathTemplate: string; + + /** + * Creates a new RoutingParameter instance using the specified properties. + * @param [properties] Properties to set + * @returns RoutingParameter instance + */ + public static create(properties?: google.api.IRoutingParameter): google.api.RoutingParameter; + + /** + * Encodes the specified RoutingParameter message. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @param message RoutingParameter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.api.IRoutingParameter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RoutingParameter message, length delimited. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @param message RoutingParameter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.api.IRoutingParameter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.api.RoutingParameter; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.api.RoutingParameter; + + /** + * Verifies a RoutingParameter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a RoutingParameter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RoutingParameter + */ + public static fromObject(object: { [k: string]: any }): google.api.RoutingParameter; + + /** + * Creates a plain object from a RoutingParameter message. Also converts values to other types if specified. + * @param message RoutingParameter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.api.RoutingParameter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RoutingParameter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RoutingParameter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Namespace protobuf. */ + namespace protobuf { + + /** Properties of a FileDescriptorSet. */ + interface IFileDescriptorSet { + + /** FileDescriptorSet file */ + file?: (google.protobuf.IFileDescriptorProto[]|null); + } + + /** Represents a FileDescriptorSet. */ + class FileDescriptorSet implements IFileDescriptorSet { + + /** + * Constructs a new FileDescriptorSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorSet); + + /** FileDescriptorSet file. */ + public file: google.protobuf.IFileDescriptorProto[]; + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @param [properties] Properties to set + * @returns FileDescriptorSet instance + */ + public static create(properties?: google.protobuf.IFileDescriptorSet): google.protobuf.FileDescriptorSet; + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @param message FileDescriptorSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFileDescriptorSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @param message FileDescriptorSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFileDescriptorSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FileDescriptorSet; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FileDescriptorSet; + + /** + * Verifies a FileDescriptorSet message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorSet; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @param message FileDescriptorSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FileDescriptorSet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Edition enum. */ + enum Edition { + EDITION_UNKNOWN = 0, + EDITION_LEGACY = 900, + EDITION_PROTO2 = 998, + EDITION_PROTO3 = 999, + EDITION_2023 = 1000, + EDITION_2024 = 1001, + 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, + EDITION_MAX = 2147483647 + } + + /** Properties of a FileDescriptorProto. */ + interface IFileDescriptorProto { + + /** FileDescriptorProto name */ + name?: (string|null); + + /** FileDescriptorProto package */ + "package"?: (string|null); + + /** FileDescriptorProto dependency */ + dependency?: (string[]|null); + + /** FileDescriptorProto publicDependency */ + publicDependency?: (number[]|null); + + /** FileDescriptorProto weakDependency */ + weakDependency?: (number[]|null); + + /** FileDescriptorProto optionDependency */ + optionDependency?: (string[]|null); + + /** FileDescriptorProto messageType */ + messageType?: (google.protobuf.IDescriptorProto[]|null); + + /** FileDescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** FileDescriptorProto service */ + service?: (google.protobuf.IServiceDescriptorProto[]|null); + + /** FileDescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** FileDescriptorProto options */ + options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo */ + sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax */ + syntax?: (string|null); + + /** FileDescriptorProto edition */ + edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FileDescriptorProto. */ + class FileDescriptorProto implements IFileDescriptorProto { + + /** + * Constructs a new FileDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileDescriptorProto); + + /** FileDescriptorProto name. */ + public name: string; + + /** FileDescriptorProto package. */ + public package: string; + + /** FileDescriptorProto dependency. */ + public dependency: string[]; + + /** FileDescriptorProto publicDependency. */ + public publicDependency: number[]; + + /** FileDescriptorProto weakDependency. */ + public weakDependency: number[]; + + /** FileDescriptorProto optionDependency. */ + public optionDependency: string[]; + + /** FileDescriptorProto messageType. */ + public messageType: google.protobuf.IDescriptorProto[]; + + /** FileDescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** FileDescriptorProto service. */ + public service: google.protobuf.IServiceDescriptorProto[]; + + /** FileDescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** FileDescriptorProto options. */ + public options?: (google.protobuf.IFileOptions|null); + + /** FileDescriptorProto sourceCodeInfo. */ + public sourceCodeInfo?: (google.protobuf.ISourceCodeInfo|null); + + /** FileDescriptorProto syntax. */ + public syntax: string; + + /** FileDescriptorProto edition. */ + public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FileDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns FileDescriptorProto instance + */ + public static create(properties?: google.protobuf.IFileDescriptorProto): google.protobuf.FileDescriptorProto; + + /** + * Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @param message FileDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFileDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @param message FileDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFileDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FileDescriptorProto; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FileDescriptorProto; + + /** + * Verifies a FileDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileDescriptorProto; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @param message FileDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FileDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DescriptorProto. */ + interface IDescriptorProto { + + /** DescriptorProto name */ + name?: (string|null); + + /** DescriptorProto field */ + field?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto extension */ + extension?: (google.protobuf.IFieldDescriptorProto[]|null); + + /** DescriptorProto nestedType */ + nestedType?: (google.protobuf.IDescriptorProto[]|null); + + /** DescriptorProto enumType */ + enumType?: (google.protobuf.IEnumDescriptorProto[]|null); + + /** DescriptorProto extensionRange */ + extensionRange?: (google.protobuf.DescriptorProto.IExtensionRange[]|null); + + /** DescriptorProto oneofDecl */ + oneofDecl?: (google.protobuf.IOneofDescriptorProto[]|null); + + /** DescriptorProto options */ + options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange */ + reservedRange?: (google.protobuf.DescriptorProto.IReservedRange[]|null); + + /** DescriptorProto reservedName */ + reservedName?: (string[]|null); + + /** DescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); + } + + /** Represents a DescriptorProto. */ + class DescriptorProto implements IDescriptorProto { + + /** + * Constructs a new DescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDescriptorProto); + + /** DescriptorProto name. */ + public name: string; + + /** DescriptorProto field. */ + public field: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto extension. */ + public extension: google.protobuf.IFieldDescriptorProto[]; + + /** DescriptorProto nestedType. */ + public nestedType: google.protobuf.IDescriptorProto[]; + + /** DescriptorProto enumType. */ + public enumType: google.protobuf.IEnumDescriptorProto[]; + + /** DescriptorProto extensionRange. */ + public extensionRange: google.protobuf.DescriptorProto.IExtensionRange[]; + + /** DescriptorProto oneofDecl. */ + public oneofDecl: google.protobuf.IOneofDescriptorProto[]; + + /** DescriptorProto options. */ + public options?: (google.protobuf.IMessageOptions|null); + + /** DescriptorProto reservedRange. */ + public reservedRange: google.protobuf.DescriptorProto.IReservedRange[]; + + /** DescriptorProto reservedName. */ + public reservedName: string[]; + + /** DescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + + /** + * Creates a new DescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns DescriptorProto instance + */ + public static create(properties?: google.protobuf.IDescriptorProto): google.protobuf.DescriptorProto; + + /** + * Encodes the specified DescriptorProto message. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @param message DescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @param message DescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DescriptorProto; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DescriptorProto; + + /** + * Verifies a DescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @param message DescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace DescriptorProto { + + /** Properties of an ExtensionRange. */ + interface IExtensionRange { + + /** ExtensionRange start */ + start?: (number|null); + + /** ExtensionRange end */ + end?: (number|null); + + /** ExtensionRange options */ + options?: (google.protobuf.IExtensionRangeOptions|null); + } + + /** Represents an ExtensionRange. */ + class ExtensionRange implements IExtensionRange { + + /** + * Constructs a new ExtensionRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IExtensionRange); + + /** ExtensionRange start. */ + public start: number; + + /** ExtensionRange end. */ + public end: number; + + /** ExtensionRange options. */ + public options?: (google.protobuf.IExtensionRangeOptions|null); + + /** + * Creates a new ExtensionRange instance using the specified properties. + * @param [properties] Properties to set + * @returns ExtensionRange instance + */ + public static create(properties?: google.protobuf.DescriptorProto.IExtensionRange): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Encodes the specified ExtensionRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @param message ExtensionRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.DescriptorProto.IExtensionRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExtensionRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @param message ExtensionRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.DescriptorProto.IExtensionRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Verifies an ExtensionRange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ExtensionRange; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @param message ExtensionRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ExtensionRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExtensionRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ReservedRange. */ + interface IReservedRange { + + /** ReservedRange start */ + start?: (number|null); + + /** ReservedRange end */ + end?: (number|null); + } + + /** Represents a ReservedRange. */ + class ReservedRange implements IReservedRange { + + /** + * Constructs a new ReservedRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.DescriptorProto.IReservedRange); + + /** ReservedRange start. */ + public start: number; + + /** ReservedRange end. */ + public end: number; + + /** + * Creates a new ReservedRange instance using the specified properties. + * @param [properties] Properties to set + * @returns ReservedRange instance + */ + public static create(properties?: google.protobuf.DescriptorProto.IReservedRange): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Encodes the specified ReservedRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @param message ReservedRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.DescriptorProto.IReservedRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ReservedRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @param message ReservedRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.DescriptorProto.IReservedRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ReservedRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Decodes a ReservedRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Verifies a ReservedRange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DescriptorProto.ReservedRange; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @param message ReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DescriptorProto.ReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ReservedRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an ExtensionRangeOptions. */ + interface IExtensionRangeOptions { + + /** ExtensionRangeOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ExtensionRangeOptions declaration */ + declaration?: (google.protobuf.ExtensionRangeOptions.IDeclaration[]|null); + + /** ExtensionRangeOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** ExtensionRangeOptions verification */ + verification?: (google.protobuf.ExtensionRangeOptions.VerificationState|keyof typeof google.protobuf.ExtensionRangeOptions.VerificationState|null); + } + + /** Represents an ExtensionRangeOptions. */ + class ExtensionRangeOptions implements IExtensionRangeOptions { + + /** + * Constructs a new ExtensionRangeOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IExtensionRangeOptions); + + /** ExtensionRangeOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** ExtensionRangeOptions declaration. */ + public declaration: google.protobuf.ExtensionRangeOptions.IDeclaration[]; + + /** ExtensionRangeOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** ExtensionRangeOptions verification. */ + public verification: (google.protobuf.ExtensionRangeOptions.VerificationState|keyof typeof google.protobuf.ExtensionRangeOptions.VerificationState); + + /** + * Creates a new ExtensionRangeOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns ExtensionRangeOptions instance + */ + public static create(properties?: google.protobuf.IExtensionRangeOptions): google.protobuf.ExtensionRangeOptions; + + /** + * Encodes the specified ExtensionRangeOptions message. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @param message ExtensionRangeOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IExtensionRangeOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ExtensionRangeOptions message, length delimited. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @param message ExtensionRangeOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IExtensionRangeOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ExtensionRangeOptions; + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ExtensionRangeOptions; + + /** + * Verifies an ExtensionRangeOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ExtensionRangeOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ExtensionRangeOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ExtensionRangeOptions; + + /** + * Creates a plain object from an ExtensionRangeOptions message. Also converts values to other types if specified. + * @param message ExtensionRangeOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ExtensionRangeOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ExtensionRangeOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ExtensionRangeOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace ExtensionRangeOptions { + + /** Properties of a Declaration. */ + interface IDeclaration { + + /** Declaration number */ + number?: (number|null); + + /** Declaration fullName */ + fullName?: (string|null); + + /** Declaration type */ + type?: (string|null); + + /** Declaration reserved */ + reserved?: (boolean|null); + + /** Declaration repeated */ + repeated?: (boolean|null); + } + + /** Represents a Declaration. */ + class Declaration implements IDeclaration { + + /** + * Constructs a new Declaration. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ExtensionRangeOptions.IDeclaration); + + /** Declaration number. */ + public number: number; + + /** Declaration fullName. */ + public fullName: string; + + /** Declaration type. */ + public type: string; + + /** Declaration reserved. */ + public reserved: boolean; + + /** Declaration repeated. */ + public repeated: boolean; + + /** + * Creates a new Declaration instance using the specified properties. + * @param [properties] Properties to set + * @returns Declaration instance + */ + public static create(properties?: google.protobuf.ExtensionRangeOptions.IDeclaration): google.protobuf.ExtensionRangeOptions.Declaration; + + /** + * Encodes the specified Declaration message. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.Declaration.verify|verify} messages. + * @param message Declaration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.ExtensionRangeOptions.IDeclaration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Declaration message, length delimited. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.Declaration.verify|verify} messages. + * @param message Declaration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.ExtensionRangeOptions.IDeclaration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Declaration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Declaration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ExtensionRangeOptions.Declaration; + + /** + * Decodes a Declaration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Declaration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ExtensionRangeOptions.Declaration; + + /** + * Verifies a Declaration message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Declaration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Declaration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ExtensionRangeOptions.Declaration; + + /** + * Creates a plain object from a Declaration message. Also converts values to other types if specified. + * @param message Declaration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ExtensionRangeOptions.Declaration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Declaration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Declaration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** VerificationState enum. */ + enum VerificationState { + DECLARATION = 0, + UNVERIFIED = 1 + } + } + + /** Properties of a FieldDescriptorProto. */ + interface IFieldDescriptorProto { + + /** FieldDescriptorProto name */ + name?: (string|null); + + /** FieldDescriptorProto number */ + number?: (number|null); + + /** FieldDescriptorProto label */ + label?: (google.protobuf.FieldDescriptorProto.Label|keyof typeof google.protobuf.FieldDescriptorProto.Label|null); + + /** FieldDescriptorProto type */ + type?: (google.protobuf.FieldDescriptorProto.Type|keyof typeof google.protobuf.FieldDescriptorProto.Type|null); + + /** FieldDescriptorProto typeName */ + typeName?: (string|null); + + /** FieldDescriptorProto extendee */ + extendee?: (string|null); + + /** FieldDescriptorProto defaultValue */ + defaultValue?: (string|null); + + /** FieldDescriptorProto oneofIndex */ + oneofIndex?: (number|null); + + /** FieldDescriptorProto jsonName */ + jsonName?: (string|null); + + /** FieldDescriptorProto options */ + options?: (google.protobuf.IFieldOptions|null); + + /** FieldDescriptorProto proto3Optional */ + proto3Optional?: (boolean|null); + } + + /** Represents a FieldDescriptorProto. */ + class FieldDescriptorProto implements IFieldDescriptorProto { + + /** + * Constructs a new FieldDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldDescriptorProto); + + /** FieldDescriptorProto name. */ + public name: string; + + /** FieldDescriptorProto number. */ + public number: number; + + /** FieldDescriptorProto label. */ + public label: (google.protobuf.FieldDescriptorProto.Label|keyof typeof google.protobuf.FieldDescriptorProto.Label); + + /** FieldDescriptorProto type. */ + public type: (google.protobuf.FieldDescriptorProto.Type|keyof typeof google.protobuf.FieldDescriptorProto.Type); + + /** FieldDescriptorProto typeName. */ + public typeName: string; + + /** FieldDescriptorProto extendee. */ + public extendee: string; + + /** FieldDescriptorProto defaultValue. */ + public defaultValue: string; + + /** FieldDescriptorProto oneofIndex. */ + public oneofIndex: number; + + /** FieldDescriptorProto jsonName. */ + public jsonName: string; + + /** FieldDescriptorProto options. */ + public options?: (google.protobuf.IFieldOptions|null); + + /** FieldDescriptorProto proto3Optional. */ + public proto3Optional: boolean; + + /** + * Creates a new FieldDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldDescriptorProto instance + */ + public static create(properties?: google.protobuf.IFieldDescriptorProto): google.protobuf.FieldDescriptorProto; + + /** + * Encodes the specified FieldDescriptorProto message. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @param message FieldDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFieldDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @param message FieldDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFieldDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldDescriptorProto; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldDescriptorProto; + + /** + * Verifies a FieldDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldDescriptorProto; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @param message FieldDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FieldDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FieldDescriptorProto { + + /** Type enum. */ + enum Type { + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + TYPE_GROUP = 10, + TYPE_MESSAGE = 11, + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + TYPE_SINT32 = 17, + TYPE_SINT64 = 18 + } + + /** Label enum. */ + enum Label { + LABEL_OPTIONAL = 1, + LABEL_REPEATED = 3, + LABEL_REQUIRED = 2 + } + } + + /** Properties of an OneofDescriptorProto. */ + interface IOneofDescriptorProto { + + /** OneofDescriptorProto name */ + name?: (string|null); + + /** OneofDescriptorProto options */ + options?: (google.protobuf.IOneofOptions|null); + } + + /** Represents an OneofDescriptorProto. */ + class OneofDescriptorProto implements IOneofDescriptorProto { + + /** + * Constructs a new OneofDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofDescriptorProto); + + /** OneofDescriptorProto name. */ + public name: string; + + /** OneofDescriptorProto options. */ + public options?: (google.protobuf.IOneofOptions|null); + + /** + * Creates a new OneofDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns OneofDescriptorProto instance + */ + public static create(properties?: google.protobuf.IOneofDescriptorProto): google.protobuf.OneofDescriptorProto; + + /** + * Encodes the specified OneofDescriptorProto message. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @param message OneofDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IOneofDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OneofDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @param message OneofDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IOneofDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.OneofDescriptorProto; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.OneofDescriptorProto; + + /** + * Verifies an OneofDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofDescriptorProto; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @param message OneofDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OneofDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an EnumDescriptorProto. */ + interface IEnumDescriptorProto { + + /** EnumDescriptorProto name */ + name?: (string|null); + + /** EnumDescriptorProto value */ + value?: (google.protobuf.IEnumValueDescriptorProto[]|null); + + /** EnumDescriptorProto options */ + options?: (google.protobuf.IEnumOptions|null); + + /** EnumDescriptorProto reservedRange */ + reservedRange?: (google.protobuf.EnumDescriptorProto.IEnumReservedRange[]|null); + + /** EnumDescriptorProto reservedName */ + reservedName?: (string[]|null); + + /** EnumDescriptorProto visibility */ + visibility?: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility|null); + } + + /** Represents an EnumDescriptorProto. */ + class EnumDescriptorProto implements IEnumDescriptorProto { + + /** + * Constructs a new EnumDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumDescriptorProto); + + /** EnumDescriptorProto name. */ + public name: string; + + /** EnumDescriptorProto value. */ + public value: google.protobuf.IEnumValueDescriptorProto[]; + + /** EnumDescriptorProto options. */ + public options?: (google.protobuf.IEnumOptions|null); + + /** EnumDescriptorProto reservedRange. */ + public reservedRange: google.protobuf.EnumDescriptorProto.IEnumReservedRange[]; + + /** EnumDescriptorProto reservedName. */ + public reservedName: string[]; + + /** EnumDescriptorProto visibility. */ + public visibility: (google.protobuf.SymbolVisibility|keyof typeof google.protobuf.SymbolVisibility); + + /** + * Creates a new EnumDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumDescriptorProto instance + */ + public static create(properties?: google.protobuf.IEnumDescriptorProto): google.protobuf.EnumDescriptorProto; + + /** + * Encodes the specified EnumDescriptorProto message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @param message EnumDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @param message EnumDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumDescriptorProto; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumDescriptorProto; + + /** + * Verifies an EnumDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @param message EnumDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace EnumDescriptorProto { + + /** Properties of an EnumReservedRange. */ + interface IEnumReservedRange { + + /** EnumReservedRange start */ + start?: (number|null); + + /** EnumReservedRange end */ + end?: (number|null); + } + + /** Represents an EnumReservedRange. */ + class EnumReservedRange implements IEnumReservedRange { + + /** + * Constructs a new EnumReservedRange. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.EnumDescriptorProto.IEnumReservedRange); + + /** EnumReservedRange start. */ + public start: number; + + /** EnumReservedRange end. */ + public end: number; + + /** + * Creates a new EnumReservedRange instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumReservedRange instance + */ + public static create(properties?: google.protobuf.EnumDescriptorProto.IEnumReservedRange): google.protobuf.EnumDescriptorProto.EnumReservedRange; + + /** + * Encodes the specified EnumReservedRange message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @param message EnumReservedRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.EnumDescriptorProto.IEnumReservedRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumReservedRange message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @param message EnumReservedRange message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.EnumDescriptorProto.IEnumReservedRange, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumDescriptorProto.EnumReservedRange; + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumDescriptorProto.EnumReservedRange; + + /** + * Verifies an EnumReservedRange message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EnumReservedRange message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumReservedRange + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumDescriptorProto.EnumReservedRange; + + /** + * Creates a plain object from an EnumReservedRange message. Also converts values to other types if specified. + * @param message EnumReservedRange + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumDescriptorProto.EnumReservedRange, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumReservedRange to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumReservedRange + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an EnumValueDescriptorProto. */ + interface IEnumValueDescriptorProto { + + /** EnumValueDescriptorProto name */ + name?: (string|null); + + /** EnumValueDescriptorProto number */ + number?: (number|null); + + /** EnumValueDescriptorProto options */ + options?: (google.protobuf.IEnumValueOptions|null); + } + + /** Represents an EnumValueDescriptorProto. */ + class EnumValueDescriptorProto implements IEnumValueDescriptorProto { + + /** + * Constructs a new EnumValueDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueDescriptorProto); + + /** EnumValueDescriptorProto name. */ + public name: string; + + /** EnumValueDescriptorProto number. */ + public number: number; + + /** EnumValueDescriptorProto options. */ + public options?: (google.protobuf.IEnumValueOptions|null); + + /** + * Creates a new EnumValueDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumValueDescriptorProto instance + */ + public static create(properties?: google.protobuf.IEnumValueDescriptorProto): google.protobuf.EnumValueDescriptorProto; + + /** + * Encodes the specified EnumValueDescriptorProto message. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @param message EnumValueDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumValueDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumValueDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @param message EnumValueDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumValueDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumValueDescriptorProto; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumValueDescriptorProto; + + /** + * Verifies an EnumValueDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueDescriptorProto; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @param message EnumValueDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumValueDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ServiceDescriptorProto. */ + interface IServiceDescriptorProto { + + /** ServiceDescriptorProto name */ + name?: (string|null); + + /** ServiceDescriptorProto method */ + method?: (google.protobuf.IMethodDescriptorProto[]|null); + + /** ServiceDescriptorProto options */ + options?: (google.protobuf.IServiceOptions|null); + } + + /** Represents a ServiceDescriptorProto. */ + class ServiceDescriptorProto implements IServiceDescriptorProto { + + /** + * Constructs a new ServiceDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceDescriptorProto); + + /** ServiceDescriptorProto name. */ + public name: string; + + /** ServiceDescriptorProto method. */ + public method: google.protobuf.IMethodDescriptorProto[]; + + /** ServiceDescriptorProto options. */ + public options?: (google.protobuf.IServiceOptions|null); + + /** + * Creates a new ServiceDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns ServiceDescriptorProto instance + */ + public static create(properties?: google.protobuf.IServiceDescriptorProto): google.protobuf.ServiceDescriptorProto; + + /** + * Encodes the specified ServiceDescriptorProto message. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @param message ServiceDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IServiceDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServiceDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @param message ServiceDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IServiceDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ServiceDescriptorProto; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ServiceDescriptorProto; + + /** + * Verifies a ServiceDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceDescriptorProto; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @param message ServiceDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServiceDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MethodDescriptorProto. */ + interface IMethodDescriptorProto { + + /** MethodDescriptorProto name */ + name?: (string|null); + + /** MethodDescriptorProto inputType */ + inputType?: (string|null); + + /** MethodDescriptorProto outputType */ + outputType?: (string|null); + + /** MethodDescriptorProto options */ + options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming */ + clientStreaming?: (boolean|null); + + /** MethodDescriptorProto serverStreaming */ + serverStreaming?: (boolean|null); + } + + /** Represents a MethodDescriptorProto. */ + class MethodDescriptorProto implements IMethodDescriptorProto { + + /** + * Constructs a new MethodDescriptorProto. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodDescriptorProto); + + /** MethodDescriptorProto name. */ + public name: string; + + /** MethodDescriptorProto inputType. */ + public inputType: string; + + /** MethodDescriptorProto outputType. */ + public outputType: string; + + /** MethodDescriptorProto options. */ + public options?: (google.protobuf.IMethodOptions|null); + + /** MethodDescriptorProto clientStreaming. */ + public clientStreaming: boolean; + + /** MethodDescriptorProto serverStreaming. */ + public serverStreaming: boolean; + + /** + * Creates a new MethodDescriptorProto instance using the specified properties. + * @param [properties] Properties to set + * @returns MethodDescriptorProto instance + */ + public static create(properties?: google.protobuf.IMethodDescriptorProto): google.protobuf.MethodDescriptorProto; + + /** + * Encodes the specified MethodDescriptorProto message. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @param message MethodDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IMethodDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MethodDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @param message MethodDescriptorProto message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IMethodDescriptorProto, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.MethodDescriptorProto; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.MethodDescriptorProto; + + /** + * Verifies a MethodDescriptorProto message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodDescriptorProto + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodDescriptorProto; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @param message MethodDescriptorProto + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodDescriptorProto, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MethodDescriptorProto + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FileOptions. */ + interface IFileOptions { + + /** FileOptions javaPackage */ + javaPackage?: (string|null); + + /** FileOptions javaOuterClassname */ + javaOuterClassname?: (string|null); + + /** FileOptions javaMultipleFiles */ + javaMultipleFiles?: (boolean|null); + + /** FileOptions javaGenerateEqualsAndHash */ + javaGenerateEqualsAndHash?: (boolean|null); + + /** FileOptions javaStringCheckUtf8 */ + javaStringCheckUtf8?: (boolean|null); + + /** FileOptions optimizeFor */ + optimizeFor?: (google.protobuf.FileOptions.OptimizeMode|keyof typeof google.protobuf.FileOptions.OptimizeMode|null); + + /** FileOptions goPackage */ + goPackage?: (string|null); + + /** FileOptions ccGenericServices */ + ccGenericServices?: (boolean|null); + + /** FileOptions javaGenericServices */ + javaGenericServices?: (boolean|null); + + /** FileOptions pyGenericServices */ + pyGenericServices?: (boolean|null); + + /** FileOptions deprecated */ + deprecated?: (boolean|null); + + /** FileOptions ccEnableArenas */ + ccEnableArenas?: (boolean|null); + + /** FileOptions objcClassPrefix */ + objcClassPrefix?: (string|null); + + /** FileOptions csharpNamespace */ + csharpNamespace?: (string|null); + + /** FileOptions swiftPrefix */ + swiftPrefix?: (string|null); + + /** FileOptions phpClassPrefix */ + phpClassPrefix?: (string|null); + + /** FileOptions phpNamespace */ + phpNamespace?: (string|null); + + /** FileOptions phpMetadataNamespace */ + phpMetadataNamespace?: (string|null); + + /** FileOptions rubyPackage */ + rubyPackage?: (string|null); + + /** FileOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** FileOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents a FileOptions. */ + class FileOptions implements IFileOptions { + + /** + * Constructs a new FileOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFileOptions); + + /** FileOptions javaPackage. */ + public javaPackage: string; + + /** FileOptions javaOuterClassname. */ + public javaOuterClassname: string; + + /** FileOptions javaMultipleFiles. */ + public javaMultipleFiles: boolean; + + /** FileOptions javaGenerateEqualsAndHash. */ + public javaGenerateEqualsAndHash: boolean; + + /** FileOptions javaStringCheckUtf8. */ + public javaStringCheckUtf8: boolean; + + /** FileOptions optimizeFor. */ + public optimizeFor: (google.protobuf.FileOptions.OptimizeMode|keyof typeof google.protobuf.FileOptions.OptimizeMode); + + /** FileOptions goPackage. */ + public goPackage: string; + + /** FileOptions ccGenericServices. */ + public ccGenericServices: boolean; + + /** FileOptions javaGenericServices. */ + public javaGenericServices: boolean; + + /** FileOptions pyGenericServices. */ + public pyGenericServices: boolean; + + /** FileOptions deprecated. */ + public deprecated: boolean; + + /** FileOptions ccEnableArenas. */ + public ccEnableArenas: boolean; + + /** FileOptions objcClassPrefix. */ + public objcClassPrefix: string; + + /** FileOptions csharpNamespace. */ + public csharpNamespace: string; + + /** FileOptions swiftPrefix. */ + public swiftPrefix: string; + + /** FileOptions phpClassPrefix. */ + public phpClassPrefix: string; + + /** FileOptions phpNamespace. */ + public phpNamespace: string; + + /** FileOptions phpMetadataNamespace. */ + public phpMetadataNamespace: string; + + /** FileOptions rubyPackage. */ + public rubyPackage: string; + + /** FileOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** FileOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new FileOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns FileOptions instance + */ + public static create(properties?: google.protobuf.IFileOptions): google.protobuf.FileOptions; + + /** + * Encodes the specified FileOptions message. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @param message FileOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFileOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FileOptions message, length delimited. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @param message FileOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFileOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FileOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FileOptions; + + /** + * Decodes a FileOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FileOptions; + + /** + * Verifies a FileOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FileOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FileOptions; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @param message FileOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FileOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FileOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FileOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FileOptions { + + /** OptimizeMode enum. */ + enum OptimizeMode { + SPEED = 1, + CODE_SIZE = 2, + LITE_RUNTIME = 3 + } + } + + /** Properties of a MessageOptions. */ + interface IMessageOptions { + + /** MessageOptions messageSetWireFormat */ + messageSetWireFormat?: (boolean|null); + + /** MessageOptions noStandardDescriptorAccessor */ + noStandardDescriptorAccessor?: (boolean|null); + + /** MessageOptions deprecated */ + deprecated?: (boolean|null); + + /** MessageOptions mapEntry */ + mapEntry?: (boolean|null); + + /** MessageOptions deprecatedLegacyJsonFieldConflicts */ + deprecatedLegacyJsonFieldConflicts?: (boolean|null); + + /** MessageOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** MessageOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents a MessageOptions. */ + class MessageOptions implements IMessageOptions { + + /** + * Constructs a new MessageOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMessageOptions); + + /** MessageOptions messageSetWireFormat. */ + public messageSetWireFormat: boolean; + + /** MessageOptions noStandardDescriptorAccessor. */ + public noStandardDescriptorAccessor: boolean; + + /** MessageOptions deprecated. */ + public deprecated: boolean; + + /** MessageOptions mapEntry. */ + public mapEntry: boolean; + + /** MessageOptions deprecatedLegacyJsonFieldConflicts. */ + public deprecatedLegacyJsonFieldConflicts: boolean; + + /** MessageOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** MessageOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new MessageOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns MessageOptions instance + */ + public static create(properties?: google.protobuf.IMessageOptions): google.protobuf.MessageOptions; + + /** + * Encodes the specified MessageOptions message. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @param message MessageOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IMessageOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MessageOptions message, length delimited. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @param message MessageOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IMessageOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MessageOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.MessageOptions; + + /** + * Decodes a MessageOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.MessageOptions; + + /** + * Verifies a MessageOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MessageOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MessageOptions; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @param message MessageOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MessageOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MessageOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MessageOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FieldOptions. */ + interface IFieldOptions { + + /** FieldOptions ctype */ + ctype?: (google.protobuf.FieldOptions.CType|keyof typeof google.protobuf.FieldOptions.CType|null); + + /** FieldOptions packed */ + packed?: (boolean|null); + + /** FieldOptions jstype */ + jstype?: (google.protobuf.FieldOptions.JSType|keyof typeof google.protobuf.FieldOptions.JSType|null); + + /** FieldOptions lazy */ + lazy?: (boolean|null); + + /** FieldOptions unverifiedLazy */ + unverifiedLazy?: (boolean|null); + + /** FieldOptions deprecated */ + deprecated?: (boolean|null); + + /** FieldOptions weak */ + weak?: (boolean|null); + + /** FieldOptions debugRedact */ + debugRedact?: (boolean|null); + + /** FieldOptions retention */ + retention?: (google.protobuf.FieldOptions.OptionRetention|keyof typeof google.protobuf.FieldOptions.OptionRetention|null); + + /** FieldOptions targets */ + targets?: (google.protobuf.FieldOptions.OptionTargetType[]|null); + + /** FieldOptions editionDefaults */ + editionDefaults?: (google.protobuf.FieldOptions.IEditionDefault[]|null); + + /** FieldOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** FieldOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + + /** FieldOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** FieldOptions .google.api.fieldBehavior */ + ".google.api.fieldBehavior"?: (google.api.FieldBehavior[]|null); + } + + /** Represents a FieldOptions. */ + class FieldOptions implements IFieldOptions { + + /** + * Constructs a new FieldOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFieldOptions); + + /** FieldOptions ctype. */ + public ctype: (google.protobuf.FieldOptions.CType|keyof typeof google.protobuf.FieldOptions.CType); + + /** FieldOptions packed. */ + public packed: boolean; + + /** FieldOptions jstype. */ + public jstype: (google.protobuf.FieldOptions.JSType|keyof typeof google.protobuf.FieldOptions.JSType); + + /** FieldOptions lazy. */ + public lazy: boolean; + + /** FieldOptions unverifiedLazy. */ + public unverifiedLazy: boolean; + + /** FieldOptions deprecated. */ + public deprecated: boolean; + + /** FieldOptions weak. */ + public weak: boolean; + + /** FieldOptions debugRedact. */ + public debugRedact: boolean; + + /** FieldOptions retention. */ + public retention: (google.protobuf.FieldOptions.OptionRetention|keyof typeof google.protobuf.FieldOptions.OptionRetention); + + /** FieldOptions targets. */ + public targets: google.protobuf.FieldOptions.OptionTargetType[]; + + /** FieldOptions editionDefaults. */ + public editionDefaults: google.protobuf.FieldOptions.IEditionDefault[]; + + /** FieldOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** FieldOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + + /** FieldOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new FieldOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns FieldOptions instance + */ + public static create(properties?: google.protobuf.IFieldOptions): google.protobuf.FieldOptions; + + /** + * Encodes the specified FieldOptions message. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @param message FieldOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFieldOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FieldOptions message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @param message FieldOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFieldOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FieldOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldOptions; + + /** + * Decodes a FieldOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldOptions; + + /** + * Verifies a FieldOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FieldOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @param message FieldOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FieldOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FieldOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FieldOptions { + + /** CType enum. */ + enum CType { + STRING = 0, + CORD = 1, + STRING_PIECE = 2 + } + + /** JSType enum. */ + enum JSType { + JS_NORMAL = 0, + JS_STRING = 1, + JS_NUMBER = 2 + } + + /** OptionRetention enum. */ + enum OptionRetention { + RETENTION_UNKNOWN = 0, + RETENTION_RUNTIME = 1, + RETENTION_SOURCE = 2 + } + + /** OptionTargetType enum. */ + enum OptionTargetType { + TARGET_TYPE_UNKNOWN = 0, + TARGET_TYPE_FILE = 1, + TARGET_TYPE_EXTENSION_RANGE = 2, + TARGET_TYPE_MESSAGE = 3, + TARGET_TYPE_FIELD = 4, + TARGET_TYPE_ONEOF = 5, + TARGET_TYPE_ENUM = 6, + TARGET_TYPE_ENUM_ENTRY = 7, + TARGET_TYPE_SERVICE = 8, + TARGET_TYPE_METHOD = 9 + } + + /** Properties of an EditionDefault. */ + interface IEditionDefault { + + /** EditionDefault edition */ + edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** EditionDefault value */ + value?: (string|null); + } + + /** Represents an EditionDefault. */ + class EditionDefault implements IEditionDefault { + + /** + * Constructs a new EditionDefault. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IEditionDefault); + + /** EditionDefault edition. */ + public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** EditionDefault value. */ + public value: string; + + /** + * Creates a new EditionDefault instance using the specified properties. + * @param [properties] Properties to set + * @returns EditionDefault instance + */ + public static create(properties?: google.protobuf.FieldOptions.IEditionDefault): google.protobuf.FieldOptions.EditionDefault; + + /** + * Encodes the specified EditionDefault message. Does not implicitly {@link google.protobuf.FieldOptions.EditionDefault.verify|verify} messages. + * @param message EditionDefault message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IEditionDefault, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EditionDefault message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.EditionDefault.verify|verify} messages. + * @param message EditionDefault message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IEditionDefault, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EditionDefault message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldOptions.EditionDefault; + + /** + * Decodes an EditionDefault message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldOptions.EditionDefault; + + /** + * Verifies an EditionDefault message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EditionDefault message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EditionDefault + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.EditionDefault; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @param message EditionDefault + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.EditionDefault, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EditionDefault to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EditionDefault + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FeatureSupport. */ + interface IFeatureSupport { + + /** FeatureSupport editionIntroduced */ + editionIntroduced?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport editionDeprecated */ + editionDeprecated?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSupport deprecationWarning */ + deprecationWarning?: (string|null); + + /** FeatureSupport editionRemoved */ + editionRemoved?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSupport. */ + class FeatureSupport implements IFeatureSupport { + + /** + * Constructs a new FeatureSupport. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FieldOptions.IFeatureSupport); + + /** FeatureSupport editionIntroduced. */ + public editionIntroduced: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport editionDeprecated. */ + public editionDeprecated: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSupport deprecationWarning. */ + public deprecationWarning: string; + + /** FeatureSupport editionRemoved. */ + public editionRemoved: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSupport instance + */ + public static create(properties?: google.protobuf.FieldOptions.IFeatureSupport): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @param message FeatureSupport message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FieldOptions.IFeatureSupport, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Verifies a FeatureSupport message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSupport + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FieldOptions.FeatureSupport; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @param message FeatureSupport + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FieldOptions.FeatureSupport, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSupport to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSupport + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of an OneofOptions. */ + interface IOneofOptions { + + /** OneofOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** OneofOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an OneofOptions. */ + class OneofOptions implements IOneofOptions { + + /** + * Constructs a new OneofOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IOneofOptions); + + /** OneofOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** OneofOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new OneofOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns OneofOptions instance + */ + public static create(properties?: google.protobuf.IOneofOptions): google.protobuf.OneofOptions; + + /** + * Encodes the specified OneofOptions message. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @param message OneofOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IOneofOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OneofOptions message, length delimited. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @param message OneofOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IOneofOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OneofOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.OneofOptions; + + /** + * Decodes an OneofOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.OneofOptions; + + /** + * Verifies an OneofOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OneofOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.OneofOptions; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @param message OneofOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.OneofOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OneofOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OneofOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an EnumOptions. */ + interface IEnumOptions { + + /** EnumOptions allowAlias */ + allowAlias?: (boolean|null); + + /** EnumOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumOptions deprecatedLegacyJsonFieldConflicts */ + deprecatedLegacyJsonFieldConflicts?: (boolean|null); + + /** EnumOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** EnumOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumOptions. */ + class EnumOptions implements IEnumOptions { + + /** + * Constructs a new EnumOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumOptions); + + /** EnumOptions allowAlias. */ + public allowAlias: boolean; + + /** EnumOptions deprecated. */ + public deprecated: boolean; + + /** EnumOptions deprecatedLegacyJsonFieldConflicts. */ + public deprecatedLegacyJsonFieldConflicts: boolean; + + /** EnumOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** EnumOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new EnumOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumOptions instance + */ + public static create(properties?: google.protobuf.IEnumOptions): google.protobuf.EnumOptions; + + /** + * Encodes the specified EnumOptions message. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @param message EnumOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @param message EnumOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumOptions; + + /** + * Decodes an EnumOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumOptions; + + /** + * Verifies an EnumOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumOptions; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @param message EnumOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an EnumValueOptions. */ + interface IEnumValueOptions { + + /** EnumValueOptions deprecated */ + deprecated?: (boolean|null); + + /** EnumValueOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** EnumValueOptions debugRedact */ + debugRedact?: (boolean|null); + + /** EnumValueOptions featureSupport */ + featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + + /** EnumValueOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + } + + /** Represents an EnumValueOptions. */ + class EnumValueOptions implements IEnumValueOptions { + + /** + * Constructs a new EnumValueOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEnumValueOptions); + + /** EnumValueOptions deprecated. */ + public deprecated: boolean; + + /** EnumValueOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** EnumValueOptions debugRedact. */ + public debugRedact: boolean; + + /** EnumValueOptions featureSupport. */ + public featureSupport?: (google.protobuf.FieldOptions.IFeatureSupport|null); + + /** EnumValueOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new EnumValueOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns EnumValueOptions instance + */ + public static create(properties?: google.protobuf.IEnumValueOptions): google.protobuf.EnumValueOptions; + + /** + * Encodes the specified EnumValueOptions message. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @param message EnumValueOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEnumValueOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified EnumValueOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @param message EnumValueOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEnumValueOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.EnumValueOptions; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.EnumValueOptions; + + /** + * Verifies an EnumValueOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns EnumValueOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.EnumValueOptions; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @param message EnumValueOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.EnumValueOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this EnumValueOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for EnumValueOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ServiceOptions. */ + interface IServiceOptions { + + /** ServiceOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** ServiceOptions deprecated */ + deprecated?: (boolean|null); + + /** ServiceOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** ServiceOptions .google.api.defaultHost */ + ".google.api.defaultHost"?: (string|null); + + /** ServiceOptions .google.api.oauthScopes */ + ".google.api.oauthScopes"?: (string|null); + + /** ServiceOptions .google.api.apiVersion */ + ".google.api.apiVersion"?: (string|null); + } + + /** Represents a ServiceOptions. */ + class ServiceOptions implements IServiceOptions { + + /** + * Constructs a new ServiceOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IServiceOptions); + + /** ServiceOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** ServiceOptions deprecated. */ + public deprecated: boolean; + + /** ServiceOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new ServiceOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns ServiceOptions instance + */ + public static create(properties?: google.protobuf.IServiceOptions): google.protobuf.ServiceOptions; + + /** + * Encodes the specified ServiceOptions message. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @param message ServiceOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IServiceOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ServiceOptions message, length delimited. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @param message ServiceOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IServiceOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ServiceOptions; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ServiceOptions; + + /** + * Verifies a ServiceOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ServiceOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ServiceOptions; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @param message ServiceOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ServiceOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ServiceOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ServiceOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a MethodOptions. */ + interface IMethodOptions { + + /** MethodOptions deprecated */ + deprecated?: (boolean|null); + + /** MethodOptions idempotencyLevel */ + idempotencyLevel?: (google.protobuf.MethodOptions.IdempotencyLevel|keyof typeof google.protobuf.MethodOptions.IdempotencyLevel|null); + + /** MethodOptions features */ + features?: (google.protobuf.IFeatureSet|null); + + /** MethodOptions uninterpretedOption */ + uninterpretedOption?: (google.protobuf.IUninterpretedOption[]|null); + + /** MethodOptions .google.api.http */ + ".google.api.http"?: (google.api.IHttpRule|null); + + /** MethodOptions .google.api.methodSignature */ + ".google.api.methodSignature"?: (string[]|null); + + /** MethodOptions .google.longrunning.operationInfo */ + ".google.longrunning.operationInfo"?: (google.longrunning.IOperationInfo|null); + + /** MethodOptions .google.api.routing */ + ".google.api.routing"?: (google.api.IRoutingRule|null); + } + + /** Represents a MethodOptions. */ + class MethodOptions implements IMethodOptions { + + /** + * Constructs a new MethodOptions. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IMethodOptions); + + /** MethodOptions deprecated. */ + public deprecated: boolean; + + /** MethodOptions idempotencyLevel. */ + public idempotencyLevel: (google.protobuf.MethodOptions.IdempotencyLevel|keyof typeof google.protobuf.MethodOptions.IdempotencyLevel); + + /** MethodOptions features. */ + public features?: (google.protobuf.IFeatureSet|null); + + /** MethodOptions uninterpretedOption. */ + public uninterpretedOption: google.protobuf.IUninterpretedOption[]; + + /** + * Creates a new MethodOptions instance using the specified properties. + * @param [properties] Properties to set + * @returns MethodOptions instance + */ + public static create(properties?: google.protobuf.IMethodOptions): google.protobuf.MethodOptions; + + /** + * Encodes the specified MethodOptions message. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @param message MethodOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IMethodOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified MethodOptions message, length delimited. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @param message MethodOptions message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IMethodOptions, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a MethodOptions message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.MethodOptions; + + /** + * Decodes a MethodOptions message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.MethodOptions; + + /** + * Verifies a MethodOptions message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns MethodOptions + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.MethodOptions; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @param message MethodOptions + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.MethodOptions, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this MethodOptions to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for MethodOptions + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace MethodOptions { + + /** IdempotencyLevel enum. */ + enum IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + NO_SIDE_EFFECTS = 1, + IDEMPOTENT = 2 + } + } + + /** Properties of an UninterpretedOption. */ + interface IUninterpretedOption { + + /** UninterpretedOption name */ + name?: (google.protobuf.UninterpretedOption.INamePart[]|null); + + /** UninterpretedOption identifierValue */ + identifierValue?: (string|null); + + /** UninterpretedOption positiveIntValue */ + positiveIntValue?: (number|Long|string|null); + + /** UninterpretedOption negativeIntValue */ + negativeIntValue?: (number|Long|string|null); + + /** UninterpretedOption doubleValue */ + doubleValue?: (number|null); + + /** UninterpretedOption stringValue */ + stringValue?: (Uint8Array|Buffer|string|null); + + /** UninterpretedOption aggregateValue */ + aggregateValue?: (string|null); + } + + /** Represents an UninterpretedOption. */ + class UninterpretedOption implements IUninterpretedOption { + + /** + * Constructs a new UninterpretedOption. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUninterpretedOption); + + /** UninterpretedOption name. */ + public name: google.protobuf.UninterpretedOption.INamePart[]; + + /** UninterpretedOption identifierValue. */ + public identifierValue: string; + + /** UninterpretedOption positiveIntValue. */ + public positiveIntValue: (number|Long|string); + + /** UninterpretedOption negativeIntValue. */ + public negativeIntValue: (number|Long|string); + + /** UninterpretedOption doubleValue. */ + public doubleValue: number; + + /** UninterpretedOption stringValue. */ + public stringValue: (Uint8Array|Buffer|string); + + /** UninterpretedOption aggregateValue. */ + public aggregateValue: string; + + /** + * Creates a new UninterpretedOption instance using the specified properties. + * @param [properties] Properties to set + * @returns UninterpretedOption instance + */ + public static create(properties?: google.protobuf.IUninterpretedOption): google.protobuf.UninterpretedOption; + + /** + * Encodes the specified UninterpretedOption message. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @param message UninterpretedOption message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IUninterpretedOption, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UninterpretedOption message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @param message UninterpretedOption message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IUninterpretedOption, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UninterpretedOption; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UninterpretedOption; + + /** + * Verifies an UninterpretedOption message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UninterpretedOption + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @param message UninterpretedOption + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UninterpretedOption to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UninterpretedOption + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace UninterpretedOption { + + /** Properties of a NamePart. */ + interface INamePart { + + /** NamePart namePart */ + namePart: string; + + /** NamePart isExtension */ + isExtension: boolean; + } + + /** Represents a NamePart. */ + class NamePart implements INamePart { + + /** + * Constructs a new NamePart. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.UninterpretedOption.INamePart); + + /** NamePart namePart. */ + public namePart: string; + + /** NamePart isExtension. */ + public isExtension: boolean; + + /** + * Creates a new NamePart instance using the specified properties. + * @param [properties] Properties to set + * @returns NamePart instance + */ + public static create(properties?: google.protobuf.UninterpretedOption.INamePart): google.protobuf.UninterpretedOption.NamePart; + + /** + * Encodes the specified NamePart message. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @param message NamePart message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.UninterpretedOption.INamePart, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified NamePart message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @param message NamePart message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.UninterpretedOption.INamePart, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a NamePart message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UninterpretedOption.NamePart; + + /** + * Decodes a NamePart message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UninterpretedOption.NamePart; + + /** + * Verifies a NamePart message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns NamePart + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UninterpretedOption.NamePart; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @param message NamePart + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UninterpretedOption.NamePart, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this NamePart to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for NamePart + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a FeatureSet. */ + interface IFeatureSet { + + /** FeatureSet fieldPresence */ + fieldPresence?: (google.protobuf.FeatureSet.FieldPresence|keyof typeof google.protobuf.FeatureSet.FieldPresence|null); + + /** FeatureSet enumType */ + enumType?: (google.protobuf.FeatureSet.EnumType|keyof typeof google.protobuf.FeatureSet.EnumType|null); + + /** FeatureSet repeatedFieldEncoding */ + repeatedFieldEncoding?: (google.protobuf.FeatureSet.RepeatedFieldEncoding|keyof typeof google.protobuf.FeatureSet.RepeatedFieldEncoding|null); + + /** FeatureSet utf8Validation */ + utf8Validation?: (google.protobuf.FeatureSet.Utf8Validation|keyof typeof google.protobuf.FeatureSet.Utf8Validation|null); + + /** FeatureSet messageEncoding */ + messageEncoding?: (google.protobuf.FeatureSet.MessageEncoding|keyof typeof google.protobuf.FeatureSet.MessageEncoding|null); + + /** FeatureSet jsonFormat */ + jsonFormat?: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat|null); + + /** FeatureSet enforceNamingStyle */ + enforceNamingStyle?: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle|null); + + /** FeatureSet defaultSymbolVisibility */ + defaultSymbolVisibility?: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null); + } + + /** Represents a FeatureSet. */ + class FeatureSet implements IFeatureSet { + + /** + * Constructs a new FeatureSet. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFeatureSet); + + /** FeatureSet fieldPresence. */ + public fieldPresence: (google.protobuf.FeatureSet.FieldPresence|keyof typeof google.protobuf.FeatureSet.FieldPresence); + + /** FeatureSet enumType. */ + public enumType: (google.protobuf.FeatureSet.EnumType|keyof typeof google.protobuf.FeatureSet.EnumType); + + /** FeatureSet repeatedFieldEncoding. */ + public repeatedFieldEncoding: (google.protobuf.FeatureSet.RepeatedFieldEncoding|keyof typeof google.protobuf.FeatureSet.RepeatedFieldEncoding); + + /** FeatureSet utf8Validation. */ + public utf8Validation: (google.protobuf.FeatureSet.Utf8Validation|keyof typeof google.protobuf.FeatureSet.Utf8Validation); + + /** FeatureSet messageEncoding. */ + public messageEncoding: (google.protobuf.FeatureSet.MessageEncoding|keyof typeof google.protobuf.FeatureSet.MessageEncoding); + + /** FeatureSet jsonFormat. */ + public jsonFormat: (google.protobuf.FeatureSet.JsonFormat|keyof typeof google.protobuf.FeatureSet.JsonFormat); + + /** FeatureSet enforceNamingStyle. */ + public enforceNamingStyle: (google.protobuf.FeatureSet.EnforceNamingStyle|keyof typeof google.protobuf.FeatureSet.EnforceNamingStyle); + + /** FeatureSet defaultSymbolVisibility. */ + public defaultSymbolVisibility: (google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|keyof typeof google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility); + + /** + * Creates a new FeatureSet instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSet instance + */ + public static create(properties?: google.protobuf.IFeatureSet): google.protobuf.FeatureSet; + + /** + * Encodes the specified FeatureSet message. Does not implicitly {@link google.protobuf.FeatureSet.verify|verify} messages. + * @param message FeatureSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFeatureSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSet message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.verify|verify} messages. + * @param message FeatureSet message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFeatureSet, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSet message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSet; + + /** + * Decodes a FeatureSet message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSet; + + /** + * Verifies a FeatureSet message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSet message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSet + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet; + + /** + * Creates a plain object from a FeatureSet message. Also converts values to other types if specified. + * @param message FeatureSet + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSet to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSet + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FeatureSet { + + /** FieldPresence enum. */ + enum FieldPresence { + FIELD_PRESENCE_UNKNOWN = 0, + EXPLICIT = 1, + IMPLICIT = 2, + LEGACY_REQUIRED = 3 + } + + /** EnumType enum. */ + enum EnumType { + ENUM_TYPE_UNKNOWN = 0, + OPEN = 1, + CLOSED = 2 + } + + /** RepeatedFieldEncoding enum. */ + enum RepeatedFieldEncoding { + REPEATED_FIELD_ENCODING_UNKNOWN = 0, + PACKED = 1, + EXPANDED = 2 + } + + /** Utf8Validation enum. */ + enum Utf8Validation { + UTF8_VALIDATION_UNKNOWN = 0, + VERIFY = 2, + NONE = 3 + } + + /** MessageEncoding enum. */ + enum MessageEncoding { + MESSAGE_ENCODING_UNKNOWN = 0, + LENGTH_PREFIXED = 1, + DELIMITED = 2 + } + + /** JsonFormat enum. */ + enum JsonFormat { + JSON_FORMAT_UNKNOWN = 0, + ALLOW = 1, + LEGACY_BEST_EFFORT = 2 + } + + /** EnforceNamingStyle enum. */ + enum EnforceNamingStyle { + ENFORCE_NAMING_STYLE_UNKNOWN = 0, + STYLE2024 = 1, + STYLE_LEGACY = 2 + } + + /** Properties of a VisibilityFeature. */ + interface IVisibilityFeature { + } + + /** Represents a VisibilityFeature. */ + class VisibilityFeature implements IVisibilityFeature { + + /** + * Constructs a new VisibilityFeature. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSet.IVisibilityFeature); + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @param [properties] Properties to set + * @returns VisibilityFeature instance + */ + public static create(properties?: google.protobuf.FeatureSet.IVisibilityFeature): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @param message VisibilityFeature message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSet.IVisibilityFeature, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Verifies a VisibilityFeature message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns VisibilityFeature + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSet.VisibilityFeature; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @param message VisibilityFeature + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSet.VisibilityFeature, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this VisibilityFeature to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for VisibilityFeature + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace VisibilityFeature { + + /** DefaultSymbolVisibility enum. */ + enum DefaultSymbolVisibility { + DEFAULT_SYMBOL_VISIBILITY_UNKNOWN = 0, + EXPORT_ALL = 1, + EXPORT_TOP_LEVEL = 2, + LOCAL_ALL = 3, + STRICT = 4 + } + } + } + + /** Properties of a FeatureSetDefaults. */ + interface IFeatureSetDefaults { + + /** FeatureSetDefaults defaults */ + defaults?: (google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault[]|null); + + /** FeatureSetDefaults minimumEdition */ + minimumEdition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSetDefaults maximumEdition */ + maximumEdition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + } + + /** Represents a FeatureSetDefaults. */ + class FeatureSetDefaults implements IFeatureSetDefaults { + + /** + * Constructs a new FeatureSetDefaults. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFeatureSetDefaults); + + /** FeatureSetDefaults defaults. */ + public defaults: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault[]; + + /** FeatureSetDefaults minimumEdition. */ + public minimumEdition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSetDefaults maximumEdition. */ + public maximumEdition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** + * Creates a new FeatureSetDefaults instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSetDefaults instance + */ + public static create(properties?: google.protobuf.IFeatureSetDefaults): google.protobuf.FeatureSetDefaults; + + /** + * Encodes the specified FeatureSetDefaults message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @param message FeatureSetDefaults message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFeatureSetDefaults, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSetDefaults message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @param message FeatureSetDefaults message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFeatureSetDefaults, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSetDefaults; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSetDefaults; + + /** + * Verifies a FeatureSetDefaults message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSetDefaults message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSetDefaults + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSetDefaults; + + /** + * Creates a plain object from a FeatureSetDefaults message. Also converts values to other types if specified. + * @param message FeatureSetDefaults + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSetDefaults, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSetDefaults to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSetDefaults + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace FeatureSetDefaults { + + /** Properties of a FeatureSetEditionDefault. */ + interface IFeatureSetEditionDefault { + + /** FeatureSetEditionDefault edition */ + edition?: (google.protobuf.Edition|keyof typeof google.protobuf.Edition|null); + + /** FeatureSetEditionDefault overridableFeatures */ + overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures */ + fixedFeatures?: (google.protobuf.IFeatureSet|null); + } + + /** Represents a FeatureSetEditionDefault. */ + class FeatureSetEditionDefault implements IFeatureSetEditionDefault { + + /** + * Constructs a new FeatureSetEditionDefault. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault); + + /** FeatureSetEditionDefault edition. */ + public edition: (google.protobuf.Edition|keyof typeof google.protobuf.Edition); + + /** FeatureSetEditionDefault overridableFeatures. */ + public overridableFeatures?: (google.protobuf.IFeatureSet|null); + + /** FeatureSetEditionDefault fixedFeatures. */ + public fixedFeatures?: (google.protobuf.IFeatureSet|null); + + /** + * Creates a new FeatureSetEditionDefault instance using the specified properties. + * @param [properties] Properties to set + * @returns FeatureSetEditionDefault instance + */ + public static create(properties?: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Encodes the specified FeatureSetEditionDefault message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @param message FeatureSetEditionDefault message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FeatureSetEditionDefault message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @param message FeatureSetEditionDefault message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Verifies a FeatureSetEditionDefault message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FeatureSetEditionDefault message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FeatureSetEditionDefault + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault; + + /** + * Creates a plain object from a FeatureSetEditionDefault message. Also converts values to other types if specified. + * @param message FeatureSetEditionDefault + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FeatureSetEditionDefault to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FeatureSetEditionDefault + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a SourceCodeInfo. */ + interface ISourceCodeInfo { + + /** SourceCodeInfo location */ + location?: (google.protobuf.SourceCodeInfo.ILocation[]|null); + } + + /** Represents a SourceCodeInfo. */ + class SourceCodeInfo implements ISourceCodeInfo { + + /** + * Constructs a new SourceCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ISourceCodeInfo); + + /** SourceCodeInfo location. */ + public location: google.protobuf.SourceCodeInfo.ILocation[]; + + /** + * Creates a new SourceCodeInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns SourceCodeInfo instance + */ + public static create(properties?: google.protobuf.ISourceCodeInfo): google.protobuf.SourceCodeInfo; + + /** + * Encodes the specified SourceCodeInfo message. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @param message SourceCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.ISourceCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SourceCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @param message SourceCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.ISourceCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.SourceCodeInfo; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.SourceCodeInfo; + + /** + * Verifies a SourceCodeInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SourceCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @param message SourceCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SourceCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SourceCodeInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace SourceCodeInfo { + + /** Properties of a Location. */ + interface ILocation { + + /** Location path */ + path?: (number[]|null); + + /** Location span */ + span?: (number[]|null); + + /** Location leadingComments */ + leadingComments?: (string|null); + + /** Location trailingComments */ + trailingComments?: (string|null); + + /** Location leadingDetachedComments */ + leadingDetachedComments?: (string[]|null); + } + + /** Represents a Location. */ + class Location implements ILocation { + + /** + * Constructs a new Location. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.SourceCodeInfo.ILocation); + + /** Location path. */ + public path: number[]; + + /** Location span. */ + public span: number[]; + + /** Location leadingComments. */ + public leadingComments: string; + + /** Location trailingComments. */ + public trailingComments: string; + + /** Location leadingDetachedComments. */ + public leadingDetachedComments: string[]; + + /** + * Creates a new Location instance using the specified properties. + * @param [properties] Properties to set + * @returns Location instance + */ + public static create(properties?: google.protobuf.SourceCodeInfo.ILocation): google.protobuf.SourceCodeInfo.Location; + + /** + * Encodes the specified Location message. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @param message Location message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.SourceCodeInfo.ILocation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Location message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @param message Location message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.SourceCodeInfo.ILocation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Location message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.SourceCodeInfo.Location; + + /** + * Decodes a Location message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.SourceCodeInfo.Location; + + /** + * Verifies a Location message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Location + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.SourceCodeInfo.Location; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @param message Location + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.SourceCodeInfo.Location, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Location to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Location + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Properties of a GeneratedCodeInfo. */ + interface IGeneratedCodeInfo { + + /** GeneratedCodeInfo annotation */ + annotation?: (google.protobuf.GeneratedCodeInfo.IAnnotation[]|null); + } + + /** Represents a GeneratedCodeInfo. */ + class GeneratedCodeInfo implements IGeneratedCodeInfo { + + /** + * Constructs a new GeneratedCodeInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IGeneratedCodeInfo); + + /** GeneratedCodeInfo annotation. */ + public annotation: google.protobuf.GeneratedCodeInfo.IAnnotation[]; + + /** + * Creates a new GeneratedCodeInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns GeneratedCodeInfo instance + */ + public static create(properties?: google.protobuf.IGeneratedCodeInfo): google.protobuf.GeneratedCodeInfo; + + /** + * Encodes the specified GeneratedCodeInfo message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @param message GeneratedCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IGeneratedCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GeneratedCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @param message GeneratedCodeInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IGeneratedCodeInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.GeneratedCodeInfo; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.GeneratedCodeInfo; + + /** + * Verifies a GeneratedCodeInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GeneratedCodeInfo + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @param message GeneratedCodeInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GeneratedCodeInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace GeneratedCodeInfo { + + /** Properties of an Annotation. */ + interface IAnnotation { + + /** Annotation path */ + path?: (number[]|null); + + /** Annotation sourceFile */ + sourceFile?: (string|null); + + /** Annotation begin */ + begin?: (number|null); + + /** Annotation end */ + end?: (number|null); + + /** Annotation semantic */ + semantic?: (google.protobuf.GeneratedCodeInfo.Annotation.Semantic|keyof typeof google.protobuf.GeneratedCodeInfo.Annotation.Semantic|null); + } + + /** Represents an Annotation. */ + class Annotation implements IAnnotation { + + /** + * Constructs a new Annotation. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation); + + /** Annotation path. */ + public path: number[]; + + /** Annotation sourceFile. */ + public sourceFile: string; + + /** Annotation begin. */ + public begin: number; + + /** Annotation end. */ + public end: number; + + /** Annotation semantic. */ + public semantic: (google.protobuf.GeneratedCodeInfo.Annotation.Semantic|keyof typeof google.protobuf.GeneratedCodeInfo.Annotation.Semantic); + + /** + * Creates a new Annotation instance using the specified properties. + * @param [properties] Properties to set + * @returns Annotation instance + */ + public static create(properties?: google.protobuf.GeneratedCodeInfo.IAnnotation): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Encodes the specified Annotation message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @param message Annotation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.GeneratedCodeInfo.IAnnotation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Annotation message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @param message Annotation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.GeneratedCodeInfo.IAnnotation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Annotation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Decodes an Annotation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Verifies an Annotation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Annotation + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.GeneratedCodeInfo.Annotation; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @param message Annotation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.GeneratedCodeInfo.Annotation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Annotation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Annotation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace Annotation { + + /** Semantic enum. */ + enum Semantic { + NONE = 0, + SET = 1, + ALIAS = 2 + } + } + } + + /** SymbolVisibility enum. */ + enum SymbolVisibility { + VISIBILITY_UNSET = 0, + VISIBILITY_LOCAL = 1, + VISIBILITY_EXPORT = 2 + } + + /** Properties of a Duration. */ + interface IDuration { + + /** Duration seconds */ + seconds?: (number|Long|string|null); + + /** Duration nanos */ + nanos?: (number|null); + } + + /** Represents a Duration. */ + class Duration implements IDuration { + + /** + * Constructs a new Duration. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDuration); + + /** Duration seconds. */ + public seconds: (number|Long|string); + + /** Duration nanos. */ + public nanos: number; + + /** + * Creates a new Duration instance using the specified properties. + * @param [properties] Properties to set + * @returns Duration instance + */ + public static create(properties?: google.protobuf.IDuration): google.protobuf.Duration; + + /** + * Encodes the specified Duration message. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @param message Duration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IDuration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Duration message, length delimited. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @param message Duration message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IDuration, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Duration message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Duration; + + /** + * Decodes a Duration message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Duration; + + /** + * Verifies a Duration message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Duration + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Duration; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @param message Duration + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Duration, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Duration to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Duration + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Any. */ + interface IAny { + + /** Any type_url */ + type_url?: (string|null); + + /** Any value */ + value?: (Uint8Array|Buffer|string|null); + } + + /** Represents an Any. */ + class Any implements IAny { + + /** + * Constructs a new Any. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IAny); + + /** Any type_url. */ + public type_url: string; + + /** Any value. */ + public value: (Uint8Array|Buffer|string); + + /** + * Creates a new Any instance using the specified properties. + * @param [properties] Properties to set + * @returns Any instance + */ + public static create(properties?: google.protobuf.IAny): google.protobuf.Any; + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @param message Any message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @param message Any message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IAny, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Any message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Any; + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Any; + + /** + * Verifies an Any message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Any + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Any; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @param message Any + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Any, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Any to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Any + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Empty. */ + interface IEmpty { + } + + /** Represents an Empty. */ + class Empty implements IEmpty { + + /** + * Constructs a new Empty. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IEmpty); + + /** + * Creates a new Empty instance using the specified properties. + * @param [properties] Properties to set + * @returns Empty instance + */ + public static create(properties?: google.protobuf.IEmpty): google.protobuf.Empty; + + /** + * Encodes the specified Empty message. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @param message Empty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IEmpty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Empty message, length delimited. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @param message Empty message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IEmpty, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Empty message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Empty; + + /** + * Decodes an Empty message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Empty; + + /** + * Verifies an Empty message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Empty + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Empty; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @param message Empty + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Empty, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Empty to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Empty + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Timestamp. */ + interface ITimestamp { + + /** Timestamp seconds */ + seconds?: (number|Long|string|null); + + /** Timestamp nanos */ + nanos?: (number|null); + } + + /** Represents a Timestamp. */ + class Timestamp implements ITimestamp { + + /** + * Constructs a new Timestamp. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.ITimestamp); + + /** Timestamp seconds. */ + public seconds: (number|Long|string); + + /** Timestamp nanos. */ + public nanos: number; + + /** + * Creates a new Timestamp instance using the specified properties. + * @param [properties] Properties to set + * @returns Timestamp instance + */ + public static create(properties?: google.protobuf.ITimestamp): google.protobuf.Timestamp; + + /** + * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @param message Timestamp message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @param message Timestamp message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.ITimestamp, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Timestamp message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Timestamp; + + /** + * Decodes a Timestamp message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Timestamp; + + /** + * Verifies a Timestamp message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Timestamp + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Timestamp; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @param message Timestamp + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Timestamp, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Timestamp to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Timestamp + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Struct. */ + interface IStruct { + + /** Struct fields */ + fields?: ({ [k: string]: google.protobuf.IValue }|null); + } + + /** Represents a Struct. */ + class Struct implements IStruct { + + /** + * Constructs a new Struct. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStruct); + + /** Struct fields. */ + public fields: { [k: string]: google.protobuf.IValue }; + + /** + * Creates a new Struct instance using the specified properties. + * @param [properties] Properties to set + * @returns Struct instance + */ + public static create(properties?: google.protobuf.IStruct): google.protobuf.Struct; + + /** + * Encodes the specified Struct message. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @param message Struct message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IStruct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Struct message, length delimited. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @param message Struct message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IStruct, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Struct message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Struct; + + /** + * Decodes a Struct message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Struct; + + /** + * Verifies a Struct message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Struct + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Struct; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @param message Struct + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Struct, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Struct to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Struct + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a Value. */ + interface IValue { + + /** Value nullValue */ + nullValue?: (google.protobuf.NullValue|keyof typeof google.protobuf.NullValue|null); + + /** Value numberValue */ + numberValue?: (number|null); + + /** Value stringValue */ + stringValue?: (string|null); + + /** Value boolValue */ + boolValue?: (boolean|null); + + /** Value structValue */ + structValue?: (google.protobuf.IStruct|null); + + /** Value listValue */ + listValue?: (google.protobuf.IListValue|null); + } + + /** Represents a Value. */ + class Value implements IValue { + + /** + * Constructs a new Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IValue); + + /** Value nullValue. */ + public nullValue?: (google.protobuf.NullValue|keyof typeof google.protobuf.NullValue|null); + + /** Value numberValue. */ + public numberValue?: (number|null); + + /** Value stringValue. */ + public stringValue?: (string|null); + + /** Value boolValue. */ + public boolValue?: (boolean|null); + + /** Value structValue. */ + public structValue?: (google.protobuf.IStruct|null); + + /** Value listValue. */ + public listValue?: (google.protobuf.IListValue|null); + + /** Value kind. */ + public kind?: ("nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"); + + /** + * Creates a new Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Value instance + */ + public static create(properties?: google.protobuf.IValue): google.protobuf.Value; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @param message Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Value; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Value; + + /** + * Verifies a Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Value; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @param message Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** NullValue enum. */ + enum NullValue { + NULL_VALUE = 0 + } + + /** Properties of a ListValue. */ + interface IListValue { + + /** ListValue values */ + values?: (google.protobuf.IValue[]|null); + } + + /** Represents a ListValue. */ + class ListValue implements IListValue { + + /** + * Constructs a new ListValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IListValue); + + /** ListValue values. */ + public values: google.protobuf.IValue[]; + + /** + * Creates a new ListValue instance using the specified properties. + * @param [properties] Properties to set + * @returns ListValue instance + */ + public static create(properties?: google.protobuf.IListValue): google.protobuf.ListValue; + + /** + * Encodes the specified ListValue message. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @param message ListValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IListValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListValue message, length delimited. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @param message ListValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IListValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.ListValue; + + /** + * Decodes a ListValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.ListValue; + + /** + * Verifies a ListValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.ListValue; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @param message ListValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.ListValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DoubleValue. */ + interface IDoubleValue { + + /** DoubleValue value */ + value?: (number|null); + } + + /** Represents a DoubleValue. */ + class DoubleValue implements IDoubleValue { + + /** + * Constructs a new DoubleValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IDoubleValue); + + /** DoubleValue value. */ + public value: number; + + /** + * Creates a new DoubleValue instance using the specified properties. + * @param [properties] Properties to set + * @returns DoubleValue instance + */ + public static create(properties?: google.protobuf.IDoubleValue): google.protobuf.DoubleValue; + + /** + * Encodes the specified DoubleValue message. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @param message DoubleValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IDoubleValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DoubleValue message, length delimited. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @param message DoubleValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IDoubleValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DoubleValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.DoubleValue; + + /** + * Decodes a DoubleValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.DoubleValue; + + /** + * Verifies a DoubleValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DoubleValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.DoubleValue; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @param message DoubleValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.DoubleValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DoubleValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DoubleValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a FloatValue. */ + interface IFloatValue { + + /** FloatValue value */ + value?: (number|null); + } + + /** Represents a FloatValue. */ + class FloatValue implements IFloatValue { + + /** + * Constructs a new FloatValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IFloatValue); + + /** FloatValue value. */ + public value: number; + + /** + * Creates a new FloatValue instance using the specified properties. + * @param [properties] Properties to set + * @returns FloatValue instance + */ + public static create(properties?: google.protobuf.IFloatValue): google.protobuf.FloatValue; + + /** + * Encodes the specified FloatValue message. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @param message FloatValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IFloatValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified FloatValue message, length delimited. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @param message FloatValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IFloatValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a FloatValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.FloatValue; + + /** + * Decodes a FloatValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.FloatValue; + + /** + * Verifies a FloatValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns FloatValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.FloatValue; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @param message FloatValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.FloatValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this FloatValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for FloatValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Int64Value. */ + interface IInt64Value { + + /** Int64Value value */ + value?: (number|Long|string|null); + } + + /** Represents an Int64Value. */ + class Int64Value implements IInt64Value { + + /** + * Constructs a new Int64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt64Value); + + /** Int64Value value. */ + public value: (number|Long|string); + + /** + * Creates a new Int64Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Int64Value instance + */ + public static create(properties?: google.protobuf.IInt64Value): google.protobuf.Int64Value; + + /** + * Encodes the specified Int64Value message. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @param message Int64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Int64Value message, length delimited. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @param message Int64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Int64Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Int64Value; + + /** + * Decodes an Int64Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Int64Value; + + /** + * Verifies an Int64Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int64Value; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @param message Int64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Int64Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UInt64Value. */ + interface IUInt64Value { + + /** UInt64Value value */ + value?: (number|Long|string|null); + } + + /** Represents a UInt64Value. */ + class UInt64Value implements IUInt64Value { + + /** + * Constructs a new UInt64Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt64Value); + + /** UInt64Value value. */ + public value: (number|Long|string); + + /** + * Creates a new UInt64Value instance using the specified properties. + * @param [properties] Properties to set + * @returns UInt64Value instance + */ + public static create(properties?: google.protobuf.IUInt64Value): google.protobuf.UInt64Value; + + /** + * Encodes the specified UInt64Value message. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @param message UInt64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IUInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UInt64Value message, length delimited. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @param message UInt64Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IUInt64Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UInt64Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UInt64Value; + + /** + * Decodes a UInt64Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UInt64Value; + + /** + * Verifies a UInt64Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt64Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt64Value; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @param message UInt64Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt64Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt64Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UInt64Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an Int32Value. */ + interface IInt32Value { + + /** Int32Value value */ + value?: (number|null); + } + + /** Represents an Int32Value. */ + class Int32Value implements IInt32Value { + + /** + * Constructs a new Int32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IInt32Value); + + /** Int32Value value. */ + public value: number; + + /** + * Creates a new Int32Value instance using the specified properties. + * @param [properties] Properties to set + * @returns Int32Value instance + */ + public static create(properties?: google.protobuf.IInt32Value): google.protobuf.Int32Value; + + /** + * Encodes the specified Int32Value message. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @param message Int32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Int32Value message, length delimited. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @param message Int32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Int32Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.Int32Value; + + /** + * Decodes an Int32Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.Int32Value; + + /** + * Verifies an Int32Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Int32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.Int32Value; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @param message Int32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.Int32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Int32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Int32Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a UInt32Value. */ + interface IUInt32Value { + + /** UInt32Value value */ + value?: (number|null); + } + + /** Represents a UInt32Value. */ + class UInt32Value implements IUInt32Value { + + /** + * Constructs a new UInt32Value. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IUInt32Value); + + /** UInt32Value value. */ + public value: number; + + /** + * Creates a new UInt32Value instance using the specified properties. + * @param [properties] Properties to set + * @returns UInt32Value instance + */ + public static create(properties?: google.protobuf.IUInt32Value): google.protobuf.UInt32Value; + + /** + * Encodes the specified UInt32Value message. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @param message UInt32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IUInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UInt32Value message, length delimited. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @param message UInt32Value message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IUInt32Value, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a UInt32Value message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.UInt32Value; + + /** + * Decodes a UInt32Value message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.UInt32Value; + + /** + * Verifies a UInt32Value message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UInt32Value + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.UInt32Value; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @param message UInt32Value + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.UInt32Value, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UInt32Value to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UInt32Value + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BoolValue. */ + interface IBoolValue { + + /** BoolValue value */ + value?: (boolean|null); + } + + /** Represents a BoolValue. */ + class BoolValue implements IBoolValue { + + /** + * Constructs a new BoolValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBoolValue); + + /** BoolValue value. */ + public value: boolean; + + /** + * Creates a new BoolValue instance using the specified properties. + * @param [properties] Properties to set + * @returns BoolValue instance + */ + public static create(properties?: google.protobuf.IBoolValue): google.protobuf.BoolValue; + + /** + * Encodes the specified BoolValue message. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @param message BoolValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IBoolValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BoolValue message, length delimited. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @param message BoolValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IBoolValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BoolValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.BoolValue; + + /** + * Decodes a BoolValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.BoolValue; + + /** + * Verifies a BoolValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BoolValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BoolValue; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @param message BoolValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BoolValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BoolValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BoolValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a StringValue. */ + interface IStringValue { + + /** StringValue value */ + value?: (string|null); + } + + /** Represents a StringValue. */ + class StringValue implements IStringValue { + + /** + * Constructs a new StringValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IStringValue); + + /** StringValue value. */ + public value: string; + + /** + * Creates a new StringValue instance using the specified properties. + * @param [properties] Properties to set + * @returns StringValue instance + */ + public static create(properties?: google.protobuf.IStringValue): google.protobuf.StringValue; + + /** + * Encodes the specified StringValue message. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @param message StringValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IStringValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified StringValue message, length delimited. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @param message StringValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IStringValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a StringValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.StringValue; + + /** + * Decodes a StringValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.StringValue; + + /** + * Verifies a StringValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns StringValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.StringValue; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @param message StringValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.StringValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this StringValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for StringValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a BytesValue. */ + interface IBytesValue { + + /** BytesValue value */ + value?: (Uint8Array|Buffer|string|null); + } + + /** Represents a BytesValue. */ + class BytesValue implements IBytesValue { + + /** + * Constructs a new BytesValue. + * @param [properties] Properties to set + */ + constructor(properties?: google.protobuf.IBytesValue); + + /** BytesValue value. */ + public value: (Uint8Array|Buffer|string); + + /** + * Creates a new BytesValue instance using the specified properties. + * @param [properties] Properties to set + * @returns BytesValue instance + */ + public static create(properties?: google.protobuf.IBytesValue): google.protobuf.BytesValue; + + /** + * Encodes the specified BytesValue message. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @param message BytesValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.protobuf.IBytesValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BytesValue message, length delimited. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @param message BytesValue message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.protobuf.IBytesValue, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BytesValue message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.protobuf.BytesValue; + + /** + * Decodes a BytesValue message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.protobuf.BytesValue; + + /** + * Verifies a BytesValue message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BytesValue + */ + public static fromObject(object: { [k: string]: any }): google.protobuf.BytesValue; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @param message BytesValue + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.protobuf.BytesValue, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BytesValue to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for BytesValue + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Namespace longrunning. */ + namespace longrunning { + + /** Represents an Operations */ + class Operations extends $protobuf.rpc.Service { + + /** + * Constructs a new Operations service. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + */ + constructor(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean); + + /** + * Creates new Operations service using the specified rpc implementation. + * @param rpcImpl RPC implementation + * @param [requestDelimited=false] Whether requests are length-delimited + * @param [responseDelimited=false] Whether responses are length-delimited + * @returns RPC service. Useful where requests and/or responses are streamed. + */ + public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): Operations; + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @param callback Node-style callback called with the error, if any, and ListOperationsResponse + */ + public listOperations(request: google.longrunning.IListOperationsRequest, callback: google.longrunning.Operations.ListOperationsCallback): void; + + /** + * Calls ListOperations. + * @param request ListOperationsRequest message or plain object + * @returns Promise + */ + public listOperations(request: google.longrunning.IListOperationsRequest): Promise; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public getOperation(request: google.longrunning.IGetOperationRequest, callback: google.longrunning.Operations.GetOperationCallback): void; + + /** + * Calls GetOperation. + * @param request GetOperationRequest message or plain object + * @returns Promise + */ + public getOperation(request: google.longrunning.IGetOperationRequest): Promise; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest, callback: google.longrunning.Operations.DeleteOperationCallback): void; + + /** + * Calls DeleteOperation. + * @param request DeleteOperationRequest message or plain object + * @returns Promise + */ + public deleteOperation(request: google.longrunning.IDeleteOperationRequest): Promise; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Empty + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest, callback: google.longrunning.Operations.CancelOperationCallback): void; + + /** + * Calls CancelOperation. + * @param request CancelOperationRequest message or plain object + * @returns Promise + */ + public cancelOperation(request: google.longrunning.ICancelOperationRequest): Promise; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest, callback: google.longrunning.Operations.WaitOperationCallback): void; + + /** + * Calls WaitOperation. + * @param request WaitOperationRequest message or plain object + * @returns Promise + */ + public waitOperation(request: google.longrunning.IWaitOperationRequest): Promise; + } + + namespace Operations { + + /** + * Callback as used by {@link google.longrunning.Operations|listOperations}. + * @param error Error, if any + * @param [response] ListOperationsResponse + */ + type ListOperationsCallback = (error: (Error|null), response?: google.longrunning.ListOperationsResponse) => void; + + /** + * Callback as used by {@link google.longrunning.Operations|getOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type GetOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + + /** + * Callback as used by {@link google.longrunning.Operations|deleteOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type DeleteOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations|cancelOperation}. + * @param error Error, if any + * @param [response] Empty + */ + type CancelOperationCallback = (error: (Error|null), response?: google.protobuf.Empty) => void; + + /** + * Callback as used by {@link google.longrunning.Operations|waitOperation}. + * @param error Error, if any + * @param [response] Operation + */ + type WaitOperationCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + } + + /** Properties of an Operation. */ + interface IOperation { + + /** Operation name */ + name?: (string|null); + + /** Operation metadata */ + metadata?: (google.protobuf.IAny|null); + + /** Operation done */ + done?: (boolean|null); + + /** Operation error */ + error?: (google.rpc.IStatus|null); + + /** Operation response */ + response?: (google.protobuf.IAny|null); + } + + /** Represents an Operation. */ + class Operation implements IOperation { + + /** + * Constructs a new Operation. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperation); + + /** Operation name. */ + public name: string; + + /** Operation metadata. */ + public metadata?: (google.protobuf.IAny|null); + + /** Operation done. */ + public done: boolean; + + /** Operation error. */ + public error?: (google.rpc.IStatus|null); + + /** Operation response. */ + public response?: (google.protobuf.IAny|null); + + /** Operation result. */ + public result?: ("error"|"response"); + + /** + * Creates a new Operation instance using the specified properties. + * @param [properties] Properties to set + * @returns Operation instance + */ + public static create(properties?: google.longrunning.IOperation): google.longrunning.Operation; + + /** + * Encodes the specified Operation message. Does not implicitly {@link google.longrunning.Operation.verify|verify} messages. + * @param message Operation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.IOperation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Operation message, length delimited. Does not implicitly {@link google.longrunning.Operation.verify|verify} messages. + * @param message Operation message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.IOperation, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an Operation message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Operation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.Operation; + + /** + * Decodes an Operation message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Operation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.Operation; + + /** + * Verifies an Operation message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Operation + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.Operation; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @param message Operation + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.Operation, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Operation to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Operation + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a GetOperationRequest. */ + interface IGetOperationRequest { + + /** GetOperationRequest name */ + name?: (string|null); + } + + /** Represents a GetOperationRequest. */ + class GetOperationRequest implements IGetOperationRequest { + + /** + * Constructs a new GetOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IGetOperationRequest); + + /** GetOperationRequest name. */ + public name: string; + + /** + * Creates a new GetOperationRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns GetOperationRequest instance + */ + public static create(properties?: google.longrunning.IGetOperationRequest): google.longrunning.GetOperationRequest; + + /** + * Encodes the specified GetOperationRequest message. Does not implicitly {@link google.longrunning.GetOperationRequest.verify|verify} messages. + * @param message GetOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.IGetOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified GetOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.GetOperationRequest.verify|verify} messages. + * @param message GetOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.IGetOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a GetOperationRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns GetOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.GetOperationRequest; + + /** + * Decodes a GetOperationRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns GetOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.GetOperationRequest; + + /** + * Verifies a GetOperationRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns GetOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.GetOperationRequest; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @param message GetOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.GetOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this GetOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for GetOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListOperationsRequest. */ + interface IListOperationsRequest { + + /** ListOperationsRequest name */ + name?: (string|null); + + /** ListOperationsRequest filter */ + filter?: (string|null); + + /** ListOperationsRequest pageSize */ + pageSize?: (number|null); + + /** ListOperationsRequest pageToken */ + pageToken?: (string|null); + } + + /** Represents a ListOperationsRequest. */ + class ListOperationsRequest implements IListOperationsRequest { + + /** + * Constructs a new ListOperationsRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsRequest); + + /** ListOperationsRequest name. */ + public name: string; + + /** ListOperationsRequest filter. */ + public filter: string; + + /** ListOperationsRequest pageSize. */ + public pageSize: number; + + /** ListOperationsRequest pageToken. */ + public pageToken: string; + + /** + * Creates a new ListOperationsRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ListOperationsRequest instance + */ + public static create(properties?: google.longrunning.IListOperationsRequest): google.longrunning.ListOperationsRequest; + + /** + * Encodes the specified ListOperationsRequest message. Does not implicitly {@link google.longrunning.ListOperationsRequest.verify|verify} messages. + * @param message ListOperationsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.IListOperationsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListOperationsRequest message, length delimited. Does not implicitly {@link google.longrunning.ListOperationsRequest.verify|verify} messages. + * @param message ListOperationsRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.IListOperationsRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListOperationsRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.ListOperationsRequest; + + /** + * Decodes a ListOperationsRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.ListOperationsRequest; + + /** + * Verifies a ListOperationsRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsRequest; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @param message ListOperationsRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListOperationsRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ListOperationsResponse. */ + interface IListOperationsResponse { + + /** ListOperationsResponse operations */ + operations?: (google.longrunning.IOperation[]|null); + + /** ListOperationsResponse nextPageToken */ + nextPageToken?: (string|null); + } + + /** Represents a ListOperationsResponse. */ + class ListOperationsResponse implements IListOperationsResponse { + + /** + * Constructs a new ListOperationsResponse. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IListOperationsResponse); + + /** ListOperationsResponse operations. */ + public operations: google.longrunning.IOperation[]; + + /** ListOperationsResponse nextPageToken. */ + public nextPageToken: string; + + /** + * Creates a new ListOperationsResponse instance using the specified properties. + * @param [properties] Properties to set + * @returns ListOperationsResponse instance + */ + public static create(properties?: google.longrunning.IListOperationsResponse): google.longrunning.ListOperationsResponse; + + /** + * Encodes the specified ListOperationsResponse message. Does not implicitly {@link google.longrunning.ListOperationsResponse.verify|verify} messages. + * @param message ListOperationsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.IListOperationsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ListOperationsResponse message, length delimited. Does not implicitly {@link google.longrunning.ListOperationsResponse.verify|verify} messages. + * @param message ListOperationsResponse message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.IListOperationsResponse, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ListOperationsResponse message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ListOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.ListOperationsResponse; + + /** + * Decodes a ListOperationsResponse message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ListOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.ListOperationsResponse; + + /** + * Verifies a ListOperationsResponse message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ListOperationsResponse + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.ListOperationsResponse; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @param message ListOperationsResponse + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.ListOperationsResponse, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ListOperationsResponse to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ListOperationsResponse + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a CancelOperationRequest. */ + interface ICancelOperationRequest { + + /** CancelOperationRequest name */ + name?: (string|null); + } + + /** Represents a CancelOperationRequest. */ + class CancelOperationRequest implements ICancelOperationRequest { + + /** + * Constructs a new CancelOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.ICancelOperationRequest); + + /** CancelOperationRequest name. */ + public name: string; + + /** + * Creates a new CancelOperationRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CancelOperationRequest instance + */ + public static create(properties?: google.longrunning.ICancelOperationRequest): google.longrunning.CancelOperationRequest; + + /** + * Encodes the specified CancelOperationRequest message. Does not implicitly {@link google.longrunning.CancelOperationRequest.verify|verify} messages. + * @param message CancelOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.ICancelOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CancelOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.CancelOperationRequest.verify|verify} messages. + * @param message CancelOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.ICancelOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CancelOperationRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CancelOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.CancelOperationRequest; + + /** + * Decodes a CancelOperationRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CancelOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.CancelOperationRequest; + + /** + * Verifies a CancelOperationRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CancelOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.CancelOperationRequest; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @param message CancelOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.CancelOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CancelOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CancelOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a DeleteOperationRequest. */ + interface IDeleteOperationRequest { + + /** DeleteOperationRequest name */ + name?: (string|null); + } + + /** Represents a DeleteOperationRequest. */ + class DeleteOperationRequest implements IDeleteOperationRequest { + + /** + * Constructs a new DeleteOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IDeleteOperationRequest); + + /** DeleteOperationRequest name. */ + public name: string; + + /** + * Creates a new DeleteOperationRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns DeleteOperationRequest instance + */ + public static create(properties?: google.longrunning.IDeleteOperationRequest): google.longrunning.DeleteOperationRequest; + + /** + * Encodes the specified DeleteOperationRequest message. Does not implicitly {@link google.longrunning.DeleteOperationRequest.verify|verify} messages. + * @param message DeleteOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.IDeleteOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified DeleteOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.DeleteOperationRequest.verify|verify} messages. + * @param message DeleteOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.IDeleteOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a DeleteOperationRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns DeleteOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.DeleteOperationRequest; + + /** + * Decodes a DeleteOperationRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns DeleteOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.DeleteOperationRequest; + + /** + * Verifies a DeleteOperationRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns DeleteOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.DeleteOperationRequest; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @param message DeleteOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.DeleteOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for DeleteOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a WaitOperationRequest. */ + interface IWaitOperationRequest { + + /** WaitOperationRequest name */ + name?: (string|null); + + /** WaitOperationRequest timeout */ + timeout?: (google.protobuf.IDuration|null); + } + + /** Represents a WaitOperationRequest. */ + class WaitOperationRequest implements IWaitOperationRequest { + + /** + * Constructs a new WaitOperationRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IWaitOperationRequest); + + /** WaitOperationRequest name. */ + public name: string; + + /** WaitOperationRequest timeout. */ + public timeout?: (google.protobuf.IDuration|null); + + /** + * Creates a new WaitOperationRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns WaitOperationRequest instance + */ + public static create(properties?: google.longrunning.IWaitOperationRequest): google.longrunning.WaitOperationRequest; + + /** + * Encodes the specified WaitOperationRequest message. Does not implicitly {@link google.longrunning.WaitOperationRequest.verify|verify} messages. + * @param message WaitOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.IWaitOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WaitOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.WaitOperationRequest.verify|verify} messages. + * @param message WaitOperationRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.IWaitOperationRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WaitOperationRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WaitOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.WaitOperationRequest; + + /** + * Decodes a WaitOperationRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WaitOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.WaitOperationRequest; + + /** + * Verifies a WaitOperationRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WaitOperationRequest + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.WaitOperationRequest; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @param message WaitOperationRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.WaitOperationRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WaitOperationRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for WaitOperationRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an OperationInfo. */ + interface IOperationInfo { + + /** OperationInfo responseType */ + responseType?: (string|null); + + /** OperationInfo metadataType */ + metadataType?: (string|null); + } + + /** Represents an OperationInfo. */ + class OperationInfo implements IOperationInfo { + + /** + * Constructs a new OperationInfo. + * @param [properties] Properties to set + */ + constructor(properties?: google.longrunning.IOperationInfo); + + /** OperationInfo responseType. */ + public responseType: string; + + /** OperationInfo metadataType. */ + public metadataType: string; + + /** + * Creates a new OperationInfo instance using the specified properties. + * @param [properties] Properties to set + * @returns OperationInfo instance + */ + public static create(properties?: google.longrunning.IOperationInfo): google.longrunning.OperationInfo; + + /** + * Encodes the specified OperationInfo message. Does not implicitly {@link google.longrunning.OperationInfo.verify|verify} messages. + * @param message OperationInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.longrunning.IOperationInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified OperationInfo message, length delimited. Does not implicitly {@link google.longrunning.OperationInfo.verify|verify} messages. + * @param message OperationInfo message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.longrunning.IOperationInfo, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an OperationInfo message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns OperationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.longrunning.OperationInfo; + + /** + * Decodes an OperationInfo message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns OperationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.longrunning.OperationInfo; + + /** + * Verifies an OperationInfo message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns OperationInfo + */ + public static fromObject(object: { [k: string]: any }): google.longrunning.OperationInfo; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @param message OperationInfo + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.longrunning.OperationInfo, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this OperationInfo to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for OperationInfo + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Namespace rpc. */ + namespace rpc { + + /** Properties of a Status. */ + interface IStatus { + + /** Status code */ + code?: (number|null); + + /** Status message */ + message?: (string|null); + + /** Status details */ + details?: (google.protobuf.IAny[]|null); + } + + /** Represents a Status. */ + class Status implements IStatus { + + /** + * Constructs a new Status. + * @param [properties] Properties to set + */ + constructor(properties?: google.rpc.IStatus); + + /** Status code. */ + public code: number; + + /** Status message. */ + public message: string; + + /** Status details. */ + public details: google.protobuf.IAny[]; + + /** + * Creates a new Status instance using the specified properties. + * @param [properties] Properties to set + * @returns Status instance + */ + public static create(properties?: google.rpc.IStatus): google.rpc.Status; + + /** + * Encodes the specified Status message. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @param message Status message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.rpc.IStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified Status message, length delimited. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @param message Status message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.rpc.IStatus, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a Status message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.rpc.Status; + + /** + * Decodes a Status message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.rpc.Status; + + /** + * Verifies a Status message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns Status + */ + public static fromObject(object: { [k: string]: any }): google.rpc.Status; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @param message Status + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.rpc.Status, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this Status to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for Status + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } + + /** Namespace type. */ + namespace type { + + /** Properties of a LatLng. */ + interface ILatLng { + + /** LatLng latitude */ + latitude?: (number|null); + + /** LatLng longitude */ + longitude?: (number|null); + } + + /** Represents a LatLng. */ + class LatLng implements ILatLng { + + /** + * Constructs a new LatLng. + * @param [properties] Properties to set + */ + constructor(properties?: google.type.ILatLng); + + /** LatLng latitude. */ + public latitude: number; + + /** LatLng longitude. */ + public longitude: number; + + /** + * Creates a new LatLng instance using the specified properties. + * @param [properties] Properties to set + * @returns LatLng instance + */ + public static create(properties?: google.type.ILatLng): google.type.LatLng; + + /** + * Encodes the specified LatLng message. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @param message LatLng message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.type.ILatLng, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified LatLng message, length delimited. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @param message LatLng message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.type.ILatLng, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a LatLng message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.type.LatLng; + + /** + * Decodes a LatLng message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.type.LatLng; + + /** + * Verifies a LatLng message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns LatLng + */ + public static fromObject(object: { [k: string]: any }): google.type.LatLng; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @param message LatLng + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.type.LatLng, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this LatLng to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for LatLng + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + } +} diff --git a/handwritten/nodejs-datastore/protos/protos.js b/handwritten/nodejs-datastore/protos/protos.js new file mode 100644 index 00000000000..c1e6ff69d1f --- /dev/null +++ b/handwritten/nodejs-datastore/protos/protos.js @@ -0,0 +1,48074 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +/*eslint-disable block-scoped-var, id-length, no-control-regex, no-magic-numbers, no-prototype-builtins, no-redeclare, no-shadow, no-var, sort-vars*/ +(function(global, factory) { /* global define, require, module */ + + /* AMD */ if (typeof define === 'function' && define.amd) + define(["protobufjs/minimal"], factory); + + /* CommonJS */ else if (typeof require === 'function' && typeof module === 'object' && module && module.exports) + module.exports = factory(require("google-gax/build/src/protobuf").protobufMinimal); + +})(this, function($protobuf) { + "use strict"; + + // Common aliases + var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util; + + // Exported root namespace + var $root = $protobuf.roots._google_cloud_datastore_protos || ($protobuf.roots._google_cloud_datastore_protos = {}); + + $root.google = (function() { + + /** + * Namespace google. + * @exports google + * @namespace + */ + var google = {}; + + google.datastore = (function() { + + /** + * Namespace datastore. + * @memberof google + * @namespace + */ + var datastore = {}; + + datastore.admin = (function() { + + /** + * Namespace admin. + * @memberof google.datastore + * @namespace + */ + var admin = {}; + + admin.v1 = (function() { + + /** + * Namespace v1. + * @memberof google.datastore.admin + * @namespace + */ + var v1 = {}; + + v1.DatastoreAdmin = (function() { + + /** + * Constructs a new DatastoreAdmin service. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a DatastoreAdmin + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function DatastoreAdmin(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (DatastoreAdmin.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = DatastoreAdmin; + + /** + * Creates new DatastoreAdmin service using the specified rpc implementation. + * @function create + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {DatastoreAdmin} RPC service. Useful where requests and/or responses are streamed. + */ + DatastoreAdmin.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|exportEntities}. + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @typedef ExportEntitiesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ExportEntities. + * @function exportEntities + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IExportEntitiesRequest} request ExportEntitiesRequest message or plain object + * @param {google.datastore.admin.v1.DatastoreAdmin.ExportEntitiesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DatastoreAdmin.prototype.exportEntities = function exportEntities(request, callback) { + return this.rpcCall(exportEntities, $root.google.datastore.admin.v1.ExportEntitiesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ExportEntities" }); + + /** + * Calls ExportEntities. + * @function exportEntities + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IExportEntitiesRequest} request ExportEntitiesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|importEntities}. + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @typedef ImportEntitiesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ImportEntities. + * @function importEntities + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IImportEntitiesRequest} request ImportEntitiesRequest message or plain object + * @param {google.datastore.admin.v1.DatastoreAdmin.ImportEntitiesCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DatastoreAdmin.prototype.importEntities = function importEntities(request, callback) { + return this.rpcCall(importEntities, $root.google.datastore.admin.v1.ImportEntitiesRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ImportEntities" }); + + /** + * Calls ImportEntities. + * @function importEntities + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IImportEntitiesRequest} request ImportEntitiesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|createIndex}. + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @typedef CreateIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls CreateIndex. + * @function createIndex + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object + * @param {google.datastore.admin.v1.DatastoreAdmin.CreateIndexCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DatastoreAdmin.prototype.createIndex = function createIndex(request, callback) { + return this.rpcCall(createIndex, $root.google.datastore.admin.v1.CreateIndexRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "CreateIndex" }); + + /** + * Calls CreateIndex. + * @function createIndex + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.ICreateIndexRequest} request CreateIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|deleteIndex}. + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @typedef DeleteIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls DeleteIndex. + * @function deleteIndex + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object + * @param {google.datastore.admin.v1.DatastoreAdmin.DeleteIndexCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DatastoreAdmin.prototype.deleteIndex = function deleteIndex(request, callback) { + return this.rpcCall(deleteIndex, $root.google.datastore.admin.v1.DeleteIndexRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "DeleteIndex" }); + + /** + * Calls DeleteIndex. + * @function deleteIndex + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IDeleteIndexRequest} request DeleteIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|getIndex}. + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @typedef GetIndexCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.admin.v1.Index} [response] Index + */ + + /** + * Calls GetIndex. + * @function getIndex + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object + * @param {google.datastore.admin.v1.DatastoreAdmin.GetIndexCallback} callback Node-style callback called with the error, if any, and Index + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DatastoreAdmin.prototype.getIndex = function getIndex(request, callback) { + return this.rpcCall(getIndex, $root.google.datastore.admin.v1.GetIndexRequest, $root.google.datastore.admin.v1.Index, request, callback); + }, "name", { value: "GetIndex" }); + + /** + * Calls GetIndex. + * @function getIndex + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IGetIndexRequest} request GetIndexRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.admin.v1.DatastoreAdmin|listIndexes}. + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @typedef ListIndexesCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.admin.v1.ListIndexesResponse} [response] ListIndexesResponse + */ + + /** + * Calls ListIndexes. + * @function listIndexes + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object + * @param {google.datastore.admin.v1.DatastoreAdmin.ListIndexesCallback} callback Node-style callback called with the error, if any, and ListIndexesResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(DatastoreAdmin.prototype.listIndexes = function listIndexes(request, callback) { + return this.rpcCall(listIndexes, $root.google.datastore.admin.v1.ListIndexesRequest, $root.google.datastore.admin.v1.ListIndexesResponse, request, callback); + }, "name", { value: "ListIndexes" }); + + /** + * Calls ListIndexes. + * @function listIndexes + * @memberof google.datastore.admin.v1.DatastoreAdmin + * @instance + * @param {google.datastore.admin.v1.IListIndexesRequest} request ListIndexesRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return DatastoreAdmin; + })(); + + v1.CommonMetadata = (function() { + + /** + * Properties of a CommonMetadata. + * @memberof google.datastore.admin.v1 + * @interface ICommonMetadata + * @property {google.protobuf.ITimestamp|null} [startTime] CommonMetadata startTime + * @property {google.protobuf.ITimestamp|null} [endTime] CommonMetadata endTime + * @property {google.datastore.admin.v1.OperationType|null} [operationType] CommonMetadata operationType + * @property {Object.|null} [labels] CommonMetadata labels + * @property {google.datastore.admin.v1.CommonMetadata.State|null} [state] CommonMetadata state + */ + + /** + * Constructs a new CommonMetadata. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a CommonMetadata. + * @implements ICommonMetadata + * @constructor + * @param {google.datastore.admin.v1.ICommonMetadata=} [properties] Properties to set + */ + function CommonMetadata(properties) { + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommonMetadata startTime. + * @member {google.protobuf.ITimestamp|null|undefined} startTime + * @memberof google.datastore.admin.v1.CommonMetadata + * @instance + */ + CommonMetadata.prototype.startTime = null; + + /** + * CommonMetadata endTime. + * @member {google.protobuf.ITimestamp|null|undefined} endTime + * @memberof google.datastore.admin.v1.CommonMetadata + * @instance + */ + CommonMetadata.prototype.endTime = null; + + /** + * CommonMetadata operationType. + * @member {google.datastore.admin.v1.OperationType} operationType + * @memberof google.datastore.admin.v1.CommonMetadata + * @instance + */ + CommonMetadata.prototype.operationType = 0; + + /** + * CommonMetadata labels. + * @member {Object.} labels + * @memberof google.datastore.admin.v1.CommonMetadata + * @instance + */ + CommonMetadata.prototype.labels = $util.emptyObject; + + /** + * CommonMetadata state. + * @member {google.datastore.admin.v1.CommonMetadata.State} state + * @memberof google.datastore.admin.v1.CommonMetadata + * @instance + */ + CommonMetadata.prototype.state = 0; + + /** + * Creates a new CommonMetadata instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {google.datastore.admin.v1.ICommonMetadata=} [properties] Properties to set + * @returns {google.datastore.admin.v1.CommonMetadata} CommonMetadata instance + */ + CommonMetadata.create = function create(properties) { + return new CommonMetadata(properties); + }; + + /** + * Encodes the specified CommonMetadata message. Does not implicitly {@link google.datastore.admin.v1.CommonMetadata.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {google.datastore.admin.v1.ICommonMetadata} message CommonMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommonMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.startTime != null && Object.hasOwnProperty.call(message, "startTime")) + $root.google.protobuf.Timestamp.encode(message.startTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.endTime != null && Object.hasOwnProperty.call(message, "endTime")) + $root.google.protobuf.Timestamp.encode(message.endTime, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.operationType != null && Object.hasOwnProperty.call(message, "operationType")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.operationType); + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.state); + return writer; + }; + + /** + * Encodes the specified CommonMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.CommonMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {google.datastore.admin.v1.ICommonMetadata} message CommonMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommonMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CommonMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.CommonMetadata} CommonMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommonMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.CommonMetadata(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.startTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 2: { + message.endTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.operationType = reader.int32(); + break; + } + case 4: { + if (message.labels === $util.emptyObject) + message.labels = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.labels[key] = value; + break; + } + case 5: { + message.state = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CommonMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.CommonMetadata} CommonMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommonMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CommonMetadata message. + * @function verify + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CommonMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.startTime != null && message.hasOwnProperty("startTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.startTime); + if (error) + return "startTime." + error; + } + if (message.endTime != null && message.hasOwnProperty("endTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.endTime); + if (error) + return "endTime." + error; + } + if (message.operationType != null && message.hasOwnProperty("operationType")) + switch (message.operationType) { + default: + return "operationType: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + break; + } + return null; + }; + + /** + * Creates a CommonMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.CommonMetadata} CommonMetadata + */ + CommonMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.CommonMetadata) + return object; + var message = new $root.google.datastore.admin.v1.CommonMetadata(); + if (object.startTime != null) { + if (typeof object.startTime !== "object") + throw TypeError(".google.datastore.admin.v1.CommonMetadata.startTime: object expected"); + message.startTime = $root.google.protobuf.Timestamp.fromObject(object.startTime); + } + if (object.endTime != null) { + if (typeof object.endTime !== "object") + throw TypeError(".google.datastore.admin.v1.CommonMetadata.endTime: object expected"); + message.endTime = $root.google.protobuf.Timestamp.fromObject(object.endTime); + } + switch (object.operationType) { + default: + if (typeof object.operationType === "number") { + message.operationType = object.operationType; + break; + } + break; + case "OPERATION_TYPE_UNSPECIFIED": + case 0: + message.operationType = 0; + break; + case "EXPORT_ENTITIES": + case 1: + message.operationType = 1; + break; + case "IMPORT_ENTITIES": + case 2: + message.operationType = 2; + break; + case "CREATE_INDEX": + case 3: + message.operationType = 3; + break; + case "DELETE_INDEX": + case 4: + message.operationType = 4; + break; + } + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.datastore.admin.v1.CommonMetadata.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + switch (object.state) { + default: + if (typeof object.state === "number") { + message.state = object.state; + break; + } + break; + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "INITIALIZING": + case 1: + message.state = 1; + break; + case "PROCESSING": + case 2: + message.state = 2; + break; + case "CANCELLING": + case 3: + message.state = 3; + break; + case "FINALIZING": + case 4: + message.state = 4; + break; + case "SUCCESSFUL": + case 5: + message.state = 5; + break; + case "FAILED": + case 6: + message.state = 6; + break; + case "CANCELLED": + case 7: + message.state = 7; + break; + } + return message; + }; + + /** + * Creates a plain object from a CommonMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {google.datastore.admin.v1.CommonMetadata} message CommonMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommonMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.startTime = null; + object.endTime = null; + object.operationType = options.enums === String ? "OPERATION_TYPE_UNSPECIFIED" : 0; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + } + if (message.startTime != null && message.hasOwnProperty("startTime")) + object.startTime = $root.google.protobuf.Timestamp.toObject(message.startTime, options); + if (message.endTime != null && message.hasOwnProperty("endTime")) + object.endTime = $root.google.protobuf.Timestamp.toObject(message.endTime, options); + if (message.operationType != null && message.hasOwnProperty("operationType")) + object.operationType = options.enums === String ? $root.google.datastore.admin.v1.OperationType[message.operationType] === undefined ? message.operationType : $root.google.datastore.admin.v1.OperationType[message.operationType] : message.operationType; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.datastore.admin.v1.CommonMetadata.State[message.state] === undefined ? message.state : $root.google.datastore.admin.v1.CommonMetadata.State[message.state] : message.state; + return object; + }; + + /** + * Converts this CommonMetadata to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.CommonMetadata + * @instance + * @returns {Object.} JSON object + */ + CommonMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CommonMetadata + * @function getTypeUrl + * @memberof google.datastore.admin.v1.CommonMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CommonMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.CommonMetadata"; + }; + + /** + * State enum. + * @name google.datastore.admin.v1.CommonMetadata.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} INITIALIZING=1 INITIALIZING value + * @property {number} PROCESSING=2 PROCESSING value + * @property {number} CANCELLING=3 CANCELLING value + * @property {number} FINALIZING=4 FINALIZING value + * @property {number} SUCCESSFUL=5 SUCCESSFUL value + * @property {number} FAILED=6 FAILED value + * @property {number} CANCELLED=7 CANCELLED value + */ + CommonMetadata.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "INITIALIZING"] = 1; + values[valuesById[2] = "PROCESSING"] = 2; + values[valuesById[3] = "CANCELLING"] = 3; + values[valuesById[4] = "FINALIZING"] = 4; + values[valuesById[5] = "SUCCESSFUL"] = 5; + values[valuesById[6] = "FAILED"] = 6; + values[valuesById[7] = "CANCELLED"] = 7; + return values; + })(); + + return CommonMetadata; + })(); + + v1.Progress = (function() { + + /** + * Properties of a Progress. + * @memberof google.datastore.admin.v1 + * @interface IProgress + * @property {number|Long|null} [workCompleted] Progress workCompleted + * @property {number|Long|null} [workEstimated] Progress workEstimated + */ + + /** + * Constructs a new Progress. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a Progress. + * @implements IProgress + * @constructor + * @param {google.datastore.admin.v1.IProgress=} [properties] Properties to set + */ + function Progress(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Progress workCompleted. + * @member {number|Long} workCompleted + * @memberof google.datastore.admin.v1.Progress + * @instance + */ + Progress.prototype.workCompleted = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Progress workEstimated. + * @member {number|Long} workEstimated + * @memberof google.datastore.admin.v1.Progress + * @instance + */ + Progress.prototype.workEstimated = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new Progress instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {google.datastore.admin.v1.IProgress=} [properties] Properties to set + * @returns {google.datastore.admin.v1.Progress} Progress instance + */ + Progress.create = function create(properties) { + return new Progress(properties); + }; + + /** + * Encodes the specified Progress message. Does not implicitly {@link google.datastore.admin.v1.Progress.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {google.datastore.admin.v1.IProgress} message Progress message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Progress.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.workCompleted != null && Object.hasOwnProperty.call(message, "workCompleted")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.workCompleted); + if (message.workEstimated != null && Object.hasOwnProperty.call(message, "workEstimated")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.workEstimated); + return writer; + }; + + /** + * Encodes the specified Progress message, length delimited. Does not implicitly {@link google.datastore.admin.v1.Progress.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {google.datastore.admin.v1.IProgress} message Progress message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Progress.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Progress message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.Progress} Progress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Progress.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.Progress(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.workCompleted = reader.int64(); + break; + } + case 2: { + message.workEstimated = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Progress message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.Progress} Progress + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Progress.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Progress message. + * @function verify + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Progress.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.workCompleted != null && message.hasOwnProperty("workCompleted")) + if (!$util.isInteger(message.workCompleted) && !(message.workCompleted && $util.isInteger(message.workCompleted.low) && $util.isInteger(message.workCompleted.high))) + return "workCompleted: integer|Long expected"; + if (message.workEstimated != null && message.hasOwnProperty("workEstimated")) + if (!$util.isInteger(message.workEstimated) && !(message.workEstimated && $util.isInteger(message.workEstimated.low) && $util.isInteger(message.workEstimated.high))) + return "workEstimated: integer|Long expected"; + return null; + }; + + /** + * Creates a Progress message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.Progress} Progress + */ + Progress.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.Progress) + return object; + var message = new $root.google.datastore.admin.v1.Progress(); + if (object.workCompleted != null) + if ($util.Long) + (message.workCompleted = $util.Long.fromValue(object.workCompleted)).unsigned = false; + else if (typeof object.workCompleted === "string") + message.workCompleted = parseInt(object.workCompleted, 10); + else if (typeof object.workCompleted === "number") + message.workCompleted = object.workCompleted; + else if (typeof object.workCompleted === "object") + message.workCompleted = new $util.LongBits(object.workCompleted.low >>> 0, object.workCompleted.high >>> 0).toNumber(); + if (object.workEstimated != null) + if ($util.Long) + (message.workEstimated = $util.Long.fromValue(object.workEstimated)).unsigned = false; + else if (typeof object.workEstimated === "string") + message.workEstimated = parseInt(object.workEstimated, 10); + else if (typeof object.workEstimated === "number") + message.workEstimated = object.workEstimated; + else if (typeof object.workEstimated === "object") + message.workEstimated = new $util.LongBits(object.workEstimated.low >>> 0, object.workEstimated.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from a Progress message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {google.datastore.admin.v1.Progress} message Progress + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Progress.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.workCompleted = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.workCompleted = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.workEstimated = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.workEstimated = options.longs === String ? "0" : 0; + } + if (message.workCompleted != null && message.hasOwnProperty("workCompleted")) + if (typeof message.workCompleted === "number") + object.workCompleted = options.longs === String ? String(message.workCompleted) : message.workCompleted; + else + object.workCompleted = options.longs === String ? $util.Long.prototype.toString.call(message.workCompleted) : options.longs === Number ? new $util.LongBits(message.workCompleted.low >>> 0, message.workCompleted.high >>> 0).toNumber() : message.workCompleted; + if (message.workEstimated != null && message.hasOwnProperty("workEstimated")) + if (typeof message.workEstimated === "number") + object.workEstimated = options.longs === String ? String(message.workEstimated) : message.workEstimated; + else + object.workEstimated = options.longs === String ? $util.Long.prototype.toString.call(message.workEstimated) : options.longs === Number ? new $util.LongBits(message.workEstimated.low >>> 0, message.workEstimated.high >>> 0).toNumber() : message.workEstimated; + return object; + }; + + /** + * Converts this Progress to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.Progress + * @instance + * @returns {Object.} JSON object + */ + Progress.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Progress + * @function getTypeUrl + * @memberof google.datastore.admin.v1.Progress + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Progress.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.Progress"; + }; + + return Progress; + })(); + + v1.ExportEntitiesRequest = (function() { + + /** + * Properties of an ExportEntitiesRequest. + * @memberof google.datastore.admin.v1 + * @interface IExportEntitiesRequest + * @property {string|null} [projectId] ExportEntitiesRequest projectId + * @property {Object.|null} [labels] ExportEntitiesRequest labels + * @property {google.datastore.admin.v1.IEntityFilter|null} [entityFilter] ExportEntitiesRequest entityFilter + * @property {string|null} [outputUrlPrefix] ExportEntitiesRequest outputUrlPrefix + */ + + /** + * Constructs a new ExportEntitiesRequest. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an ExportEntitiesRequest. + * @implements IExportEntitiesRequest + * @constructor + * @param {google.datastore.admin.v1.IExportEntitiesRequest=} [properties] Properties to set + */ + function ExportEntitiesRequest(properties) { + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportEntitiesRequest projectId. + * @member {string} projectId + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @instance + */ + ExportEntitiesRequest.prototype.projectId = ""; + + /** + * ExportEntitiesRequest labels. + * @member {Object.} labels + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @instance + */ + ExportEntitiesRequest.prototype.labels = $util.emptyObject; + + /** + * ExportEntitiesRequest entityFilter. + * @member {google.datastore.admin.v1.IEntityFilter|null|undefined} entityFilter + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @instance + */ + ExportEntitiesRequest.prototype.entityFilter = null; + + /** + * ExportEntitiesRequest outputUrlPrefix. + * @member {string} outputUrlPrefix + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @instance + */ + ExportEntitiesRequest.prototype.outputUrlPrefix = ""; + + /** + * Creates a new ExportEntitiesRequest instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.IExportEntitiesRequest=} [properties] Properties to set + * @returns {google.datastore.admin.v1.ExportEntitiesRequest} ExportEntitiesRequest instance + */ + ExportEntitiesRequest.create = function create(properties) { + return new ExportEntitiesRequest(properties); + }; + + /** + * Encodes the specified ExportEntitiesRequest message. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.IExportEntitiesRequest} message ExportEntitiesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportEntitiesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.projectId); + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.entityFilter != null && Object.hasOwnProperty.call(message, "entityFilter")) + $root.google.datastore.admin.v1.EntityFilter.encode(message.entityFilter, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.outputUrlPrefix != null && Object.hasOwnProperty.call(message, "outputUrlPrefix")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.outputUrlPrefix); + return writer; + }; + + /** + * Encodes the specified ExportEntitiesRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.IExportEntitiesRequest} message ExportEntitiesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportEntitiesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportEntitiesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.ExportEntitiesRequest} ExportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportEntitiesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.ExportEntitiesRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.projectId = reader.string(); + break; + } + case 2: { + if (message.labels === $util.emptyObject) + message.labels = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.labels[key] = value; + break; + } + case 3: { + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.decode(reader, reader.uint32()); + break; + } + case 4: { + message.outputUrlPrefix = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportEntitiesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.ExportEntitiesRequest} ExportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportEntitiesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportEntitiesRequest message. + * @function verify + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportEntitiesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) { + var error = $root.google.datastore.admin.v1.EntityFilter.verify(message.entityFilter); + if (error) + return "entityFilter." + error; + } + if (message.outputUrlPrefix != null && message.hasOwnProperty("outputUrlPrefix")) + if (!$util.isString(message.outputUrlPrefix)) + return "outputUrlPrefix: string expected"; + return null; + }; + + /** + * Creates an ExportEntitiesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.ExportEntitiesRequest} ExportEntitiesRequest + */ + ExportEntitiesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.ExportEntitiesRequest) + return object; + var message = new $root.google.datastore.admin.v1.ExportEntitiesRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.datastore.admin.v1.ExportEntitiesRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + if (object.entityFilter != null) { + if (typeof object.entityFilter !== "object") + throw TypeError(".google.datastore.admin.v1.ExportEntitiesRequest.entityFilter: object expected"); + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.fromObject(object.entityFilter); + } + if (object.outputUrlPrefix != null) + message.outputUrlPrefix = String(object.outputUrlPrefix); + return message; + }; + + /** + * Creates a plain object from an ExportEntitiesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.ExportEntitiesRequest} message ExportEntitiesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportEntitiesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.projectId = ""; + object.entityFilter = null; + object.outputUrlPrefix = ""; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) + object.entityFilter = $root.google.datastore.admin.v1.EntityFilter.toObject(message.entityFilter, options); + if (message.outputUrlPrefix != null && message.hasOwnProperty("outputUrlPrefix")) + object.outputUrlPrefix = message.outputUrlPrefix; + return object; + }; + + /** + * Converts this ExportEntitiesRequest to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @instance + * @returns {Object.} JSON object + */ + ExportEntitiesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportEntitiesRequest + * @function getTypeUrl + * @memberof google.datastore.admin.v1.ExportEntitiesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportEntitiesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.ExportEntitiesRequest"; + }; + + return ExportEntitiesRequest; + })(); + + v1.ImportEntitiesRequest = (function() { + + /** + * Properties of an ImportEntitiesRequest. + * @memberof google.datastore.admin.v1 + * @interface IImportEntitiesRequest + * @property {string|null} [projectId] ImportEntitiesRequest projectId + * @property {Object.|null} [labels] ImportEntitiesRequest labels + * @property {string|null} [inputUrl] ImportEntitiesRequest inputUrl + * @property {google.datastore.admin.v1.IEntityFilter|null} [entityFilter] ImportEntitiesRequest entityFilter + */ + + /** + * Constructs a new ImportEntitiesRequest. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an ImportEntitiesRequest. + * @implements IImportEntitiesRequest + * @constructor + * @param {google.datastore.admin.v1.IImportEntitiesRequest=} [properties] Properties to set + */ + function ImportEntitiesRequest(properties) { + this.labels = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ImportEntitiesRequest projectId. + * @member {string} projectId + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @instance + */ + ImportEntitiesRequest.prototype.projectId = ""; + + /** + * ImportEntitiesRequest labels. + * @member {Object.} labels + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @instance + */ + ImportEntitiesRequest.prototype.labels = $util.emptyObject; + + /** + * ImportEntitiesRequest inputUrl. + * @member {string} inputUrl + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @instance + */ + ImportEntitiesRequest.prototype.inputUrl = ""; + + /** + * ImportEntitiesRequest entityFilter. + * @member {google.datastore.admin.v1.IEntityFilter|null|undefined} entityFilter + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @instance + */ + ImportEntitiesRequest.prototype.entityFilter = null; + + /** + * Creates a new ImportEntitiesRequest instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.IImportEntitiesRequest=} [properties] Properties to set + * @returns {google.datastore.admin.v1.ImportEntitiesRequest} ImportEntitiesRequest instance + */ + ImportEntitiesRequest.create = function create(properties) { + return new ImportEntitiesRequest(properties); + }; + + /** + * Encodes the specified ImportEntitiesRequest message. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.IImportEntitiesRequest} message ImportEntitiesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportEntitiesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.projectId); + if (message.labels != null && Object.hasOwnProperty.call(message, "labels")) + for (var keys = Object.keys(message.labels), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.labels[keys[i]]).ldelim(); + if (message.inputUrl != null && Object.hasOwnProperty.call(message, "inputUrl")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.inputUrl); + if (message.entityFilter != null && Object.hasOwnProperty.call(message, "entityFilter")) + $root.google.datastore.admin.v1.EntityFilter.encode(message.entityFilter, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ImportEntitiesRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.IImportEntitiesRequest} message ImportEntitiesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportEntitiesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportEntitiesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.ImportEntitiesRequest} ImportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportEntitiesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.ImportEntitiesRequest(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.projectId = reader.string(); + break; + } + case 2: { + if (message.labels === $util.emptyObject) + message.labels = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.labels[key] = value; + break; + } + case 3: { + message.inputUrl = reader.string(); + break; + } + case 4: { + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportEntitiesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.ImportEntitiesRequest} ImportEntitiesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportEntitiesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportEntitiesRequest message. + * @function verify + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportEntitiesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.labels != null && message.hasOwnProperty("labels")) { + if (!$util.isObject(message.labels)) + return "labels: object expected"; + var key = Object.keys(message.labels); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.labels[key[i]])) + return "labels: string{k:string} expected"; + } + if (message.inputUrl != null && message.hasOwnProperty("inputUrl")) + if (!$util.isString(message.inputUrl)) + return "inputUrl: string expected"; + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) { + var error = $root.google.datastore.admin.v1.EntityFilter.verify(message.entityFilter); + if (error) + return "entityFilter." + error; + } + return null; + }; + + /** + * Creates an ImportEntitiesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.ImportEntitiesRequest} ImportEntitiesRequest + */ + ImportEntitiesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.ImportEntitiesRequest) + return object; + var message = new $root.google.datastore.admin.v1.ImportEntitiesRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.labels) { + if (typeof object.labels !== "object") + throw TypeError(".google.datastore.admin.v1.ImportEntitiesRequest.labels: object expected"); + message.labels = {}; + for (var keys = Object.keys(object.labels), i = 0; i < keys.length; ++i) + message.labels[keys[i]] = String(object.labels[keys[i]]); + } + if (object.inputUrl != null) + message.inputUrl = String(object.inputUrl); + if (object.entityFilter != null) { + if (typeof object.entityFilter !== "object") + throw TypeError(".google.datastore.admin.v1.ImportEntitiesRequest.entityFilter: object expected"); + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.fromObject(object.entityFilter); + } + return message; + }; + + /** + * Creates a plain object from an ImportEntitiesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {google.datastore.admin.v1.ImportEntitiesRequest} message ImportEntitiesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportEntitiesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.labels = {}; + if (options.defaults) { + object.projectId = ""; + object.inputUrl = ""; + object.entityFilter = null; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + var keys2; + if (message.labels && (keys2 = Object.keys(message.labels)).length) { + object.labels = {}; + for (var j = 0; j < keys2.length; ++j) + object.labels[keys2[j]] = message.labels[keys2[j]]; + } + if (message.inputUrl != null && message.hasOwnProperty("inputUrl")) + object.inputUrl = message.inputUrl; + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) + object.entityFilter = $root.google.datastore.admin.v1.EntityFilter.toObject(message.entityFilter, options); + return object; + }; + + /** + * Converts this ImportEntitiesRequest to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @instance + * @returns {Object.} JSON object + */ + ImportEntitiesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportEntitiesRequest + * @function getTypeUrl + * @memberof google.datastore.admin.v1.ImportEntitiesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportEntitiesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.ImportEntitiesRequest"; + }; + + return ImportEntitiesRequest; + })(); + + v1.ExportEntitiesResponse = (function() { + + /** + * Properties of an ExportEntitiesResponse. + * @memberof google.datastore.admin.v1 + * @interface IExportEntitiesResponse + * @property {string|null} [outputUrl] ExportEntitiesResponse outputUrl + */ + + /** + * Constructs a new ExportEntitiesResponse. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an ExportEntitiesResponse. + * @implements IExportEntitiesResponse + * @constructor + * @param {google.datastore.admin.v1.IExportEntitiesResponse=} [properties] Properties to set + */ + function ExportEntitiesResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportEntitiesResponse outputUrl. + * @member {string} outputUrl + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @instance + */ + ExportEntitiesResponse.prototype.outputUrl = ""; + + /** + * Creates a new ExportEntitiesResponse instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {google.datastore.admin.v1.IExportEntitiesResponse=} [properties] Properties to set + * @returns {google.datastore.admin.v1.ExportEntitiesResponse} ExportEntitiesResponse instance + */ + ExportEntitiesResponse.create = function create(properties) { + return new ExportEntitiesResponse(properties); + }; + + /** + * Encodes the specified ExportEntitiesResponse message. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {google.datastore.admin.v1.IExportEntitiesResponse} message ExportEntitiesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportEntitiesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.outputUrl != null && Object.hasOwnProperty.call(message, "outputUrl")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.outputUrl); + return writer; + }; + + /** + * Encodes the specified ExportEntitiesResponse message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {google.datastore.admin.v1.IExportEntitiesResponse} message ExportEntitiesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportEntitiesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportEntitiesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.ExportEntitiesResponse} ExportEntitiesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportEntitiesResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.ExportEntitiesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.outputUrl = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportEntitiesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.ExportEntitiesResponse} ExportEntitiesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportEntitiesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportEntitiesResponse message. + * @function verify + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportEntitiesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.outputUrl != null && message.hasOwnProperty("outputUrl")) + if (!$util.isString(message.outputUrl)) + return "outputUrl: string expected"; + return null; + }; + + /** + * Creates an ExportEntitiesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.ExportEntitiesResponse} ExportEntitiesResponse + */ + ExportEntitiesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.ExportEntitiesResponse) + return object; + var message = new $root.google.datastore.admin.v1.ExportEntitiesResponse(); + if (object.outputUrl != null) + message.outputUrl = String(object.outputUrl); + return message; + }; + + /** + * Creates a plain object from an ExportEntitiesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {google.datastore.admin.v1.ExportEntitiesResponse} message ExportEntitiesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportEntitiesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.outputUrl = ""; + if (message.outputUrl != null && message.hasOwnProperty("outputUrl")) + object.outputUrl = message.outputUrl; + return object; + }; + + /** + * Converts this ExportEntitiesResponse to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @instance + * @returns {Object.} JSON object + */ + ExportEntitiesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportEntitiesResponse + * @function getTypeUrl + * @memberof google.datastore.admin.v1.ExportEntitiesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportEntitiesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.ExportEntitiesResponse"; + }; + + return ExportEntitiesResponse; + })(); + + v1.ExportEntitiesMetadata = (function() { + + /** + * Properties of an ExportEntitiesMetadata. + * @memberof google.datastore.admin.v1 + * @interface IExportEntitiesMetadata + * @property {google.datastore.admin.v1.ICommonMetadata|null} [common] ExportEntitiesMetadata common + * @property {google.datastore.admin.v1.IProgress|null} [progressEntities] ExportEntitiesMetadata progressEntities + * @property {google.datastore.admin.v1.IProgress|null} [progressBytes] ExportEntitiesMetadata progressBytes + * @property {google.datastore.admin.v1.IEntityFilter|null} [entityFilter] ExportEntitiesMetadata entityFilter + * @property {string|null} [outputUrlPrefix] ExportEntitiesMetadata outputUrlPrefix + */ + + /** + * Constructs a new ExportEntitiesMetadata. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an ExportEntitiesMetadata. + * @implements IExportEntitiesMetadata + * @constructor + * @param {google.datastore.admin.v1.IExportEntitiesMetadata=} [properties] Properties to set + */ + function ExportEntitiesMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExportEntitiesMetadata common. + * @member {google.datastore.admin.v1.ICommonMetadata|null|undefined} common + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @instance + */ + ExportEntitiesMetadata.prototype.common = null; + + /** + * ExportEntitiesMetadata progressEntities. + * @member {google.datastore.admin.v1.IProgress|null|undefined} progressEntities + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @instance + */ + ExportEntitiesMetadata.prototype.progressEntities = null; + + /** + * ExportEntitiesMetadata progressBytes. + * @member {google.datastore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @instance + */ + ExportEntitiesMetadata.prototype.progressBytes = null; + + /** + * ExportEntitiesMetadata entityFilter. + * @member {google.datastore.admin.v1.IEntityFilter|null|undefined} entityFilter + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @instance + */ + ExportEntitiesMetadata.prototype.entityFilter = null; + + /** + * ExportEntitiesMetadata outputUrlPrefix. + * @member {string} outputUrlPrefix + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @instance + */ + ExportEntitiesMetadata.prototype.outputUrlPrefix = ""; + + /** + * Creates a new ExportEntitiesMetadata instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.IExportEntitiesMetadata=} [properties] Properties to set + * @returns {google.datastore.admin.v1.ExportEntitiesMetadata} ExportEntitiesMetadata instance + */ + ExportEntitiesMetadata.create = function create(properties) { + return new ExportEntitiesMetadata(properties); + }; + + /** + * Encodes the specified ExportEntitiesMetadata message. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesMetadata.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.IExportEntitiesMetadata} message ExportEntitiesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportEntitiesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.datastore.admin.v1.CommonMetadata.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.progressEntities != null && Object.hasOwnProperty.call(message, "progressEntities")) + $root.google.datastore.admin.v1.Progress.encode(message.progressEntities, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.progressBytes != null && Object.hasOwnProperty.call(message, "progressBytes")) + $root.google.datastore.admin.v1.Progress.encode(message.progressBytes, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.entityFilter != null && Object.hasOwnProperty.call(message, "entityFilter")) + $root.google.datastore.admin.v1.EntityFilter.encode(message.entityFilter, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.outputUrlPrefix != null && Object.hasOwnProperty.call(message, "outputUrlPrefix")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.outputUrlPrefix); + return writer; + }; + + /** + * Encodes the specified ExportEntitiesMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ExportEntitiesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.IExportEntitiesMetadata} message ExportEntitiesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExportEntitiesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExportEntitiesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.ExportEntitiesMetadata} ExportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportEntitiesMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.ExportEntitiesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.datastore.admin.v1.CommonMetadata.decode(reader, reader.uint32()); + break; + } + case 2: { + message.progressEntities = $root.google.datastore.admin.v1.Progress.decode(reader, reader.uint32()); + break; + } + case 3: { + message.progressBytes = $root.google.datastore.admin.v1.Progress.decode(reader, reader.uint32()); + break; + } + case 4: { + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.decode(reader, reader.uint32()); + break; + } + case 5: { + message.outputUrlPrefix = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExportEntitiesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.ExportEntitiesMetadata} ExportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExportEntitiesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExportEntitiesMetadata message. + * @function verify + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExportEntitiesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.datastore.admin.v1.CommonMetadata.verify(message.common); + if (error) + return "common." + error; + } + if (message.progressEntities != null && message.hasOwnProperty("progressEntities")) { + var error = $root.google.datastore.admin.v1.Progress.verify(message.progressEntities); + if (error) + return "progressEntities." + error; + } + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) { + var error = $root.google.datastore.admin.v1.Progress.verify(message.progressBytes); + if (error) + return "progressBytes." + error; + } + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) { + var error = $root.google.datastore.admin.v1.EntityFilter.verify(message.entityFilter); + if (error) + return "entityFilter." + error; + } + if (message.outputUrlPrefix != null && message.hasOwnProperty("outputUrlPrefix")) + if (!$util.isString(message.outputUrlPrefix)) + return "outputUrlPrefix: string expected"; + return null; + }; + + /** + * Creates an ExportEntitiesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.ExportEntitiesMetadata} ExportEntitiesMetadata + */ + ExportEntitiesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.ExportEntitiesMetadata) + return object; + var message = new $root.google.datastore.admin.v1.ExportEntitiesMetadata(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.datastore.admin.v1.ExportEntitiesMetadata.common: object expected"); + message.common = $root.google.datastore.admin.v1.CommonMetadata.fromObject(object.common); + } + if (object.progressEntities != null) { + if (typeof object.progressEntities !== "object") + throw TypeError(".google.datastore.admin.v1.ExportEntitiesMetadata.progressEntities: object expected"); + message.progressEntities = $root.google.datastore.admin.v1.Progress.fromObject(object.progressEntities); + } + if (object.progressBytes != null) { + if (typeof object.progressBytes !== "object") + throw TypeError(".google.datastore.admin.v1.ExportEntitiesMetadata.progressBytes: object expected"); + message.progressBytes = $root.google.datastore.admin.v1.Progress.fromObject(object.progressBytes); + } + if (object.entityFilter != null) { + if (typeof object.entityFilter !== "object") + throw TypeError(".google.datastore.admin.v1.ExportEntitiesMetadata.entityFilter: object expected"); + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.fromObject(object.entityFilter); + } + if (object.outputUrlPrefix != null) + message.outputUrlPrefix = String(object.outputUrlPrefix); + return message; + }; + + /** + * Creates a plain object from an ExportEntitiesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.ExportEntitiesMetadata} message ExportEntitiesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExportEntitiesMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.common = null; + object.progressEntities = null; + object.progressBytes = null; + object.entityFilter = null; + object.outputUrlPrefix = ""; + } + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.datastore.admin.v1.CommonMetadata.toObject(message.common, options); + if (message.progressEntities != null && message.hasOwnProperty("progressEntities")) + object.progressEntities = $root.google.datastore.admin.v1.Progress.toObject(message.progressEntities, options); + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) + object.progressBytes = $root.google.datastore.admin.v1.Progress.toObject(message.progressBytes, options); + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) + object.entityFilter = $root.google.datastore.admin.v1.EntityFilter.toObject(message.entityFilter, options); + if (message.outputUrlPrefix != null && message.hasOwnProperty("outputUrlPrefix")) + object.outputUrlPrefix = message.outputUrlPrefix; + return object; + }; + + /** + * Converts this ExportEntitiesMetadata to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @instance + * @returns {Object.} JSON object + */ + ExportEntitiesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExportEntitiesMetadata + * @function getTypeUrl + * @memberof google.datastore.admin.v1.ExportEntitiesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExportEntitiesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.ExportEntitiesMetadata"; + }; + + return ExportEntitiesMetadata; + })(); + + v1.ImportEntitiesMetadata = (function() { + + /** + * Properties of an ImportEntitiesMetadata. + * @memberof google.datastore.admin.v1 + * @interface IImportEntitiesMetadata + * @property {google.datastore.admin.v1.ICommonMetadata|null} [common] ImportEntitiesMetadata common + * @property {google.datastore.admin.v1.IProgress|null} [progressEntities] ImportEntitiesMetadata progressEntities + * @property {google.datastore.admin.v1.IProgress|null} [progressBytes] ImportEntitiesMetadata progressBytes + * @property {google.datastore.admin.v1.IEntityFilter|null} [entityFilter] ImportEntitiesMetadata entityFilter + * @property {string|null} [inputUrl] ImportEntitiesMetadata inputUrl + */ + + /** + * Constructs a new ImportEntitiesMetadata. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an ImportEntitiesMetadata. + * @implements IImportEntitiesMetadata + * @constructor + * @param {google.datastore.admin.v1.IImportEntitiesMetadata=} [properties] Properties to set + */ + function ImportEntitiesMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ImportEntitiesMetadata common. + * @member {google.datastore.admin.v1.ICommonMetadata|null|undefined} common + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @instance + */ + ImportEntitiesMetadata.prototype.common = null; + + /** + * ImportEntitiesMetadata progressEntities. + * @member {google.datastore.admin.v1.IProgress|null|undefined} progressEntities + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @instance + */ + ImportEntitiesMetadata.prototype.progressEntities = null; + + /** + * ImportEntitiesMetadata progressBytes. + * @member {google.datastore.admin.v1.IProgress|null|undefined} progressBytes + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @instance + */ + ImportEntitiesMetadata.prototype.progressBytes = null; + + /** + * ImportEntitiesMetadata entityFilter. + * @member {google.datastore.admin.v1.IEntityFilter|null|undefined} entityFilter + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @instance + */ + ImportEntitiesMetadata.prototype.entityFilter = null; + + /** + * ImportEntitiesMetadata inputUrl. + * @member {string} inputUrl + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @instance + */ + ImportEntitiesMetadata.prototype.inputUrl = ""; + + /** + * Creates a new ImportEntitiesMetadata instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.IImportEntitiesMetadata=} [properties] Properties to set + * @returns {google.datastore.admin.v1.ImportEntitiesMetadata} ImportEntitiesMetadata instance + */ + ImportEntitiesMetadata.create = function create(properties) { + return new ImportEntitiesMetadata(properties); + }; + + /** + * Encodes the specified ImportEntitiesMetadata message. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesMetadata.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.IImportEntitiesMetadata} message ImportEntitiesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportEntitiesMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.datastore.admin.v1.CommonMetadata.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.progressEntities != null && Object.hasOwnProperty.call(message, "progressEntities")) + $root.google.datastore.admin.v1.Progress.encode(message.progressEntities, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.progressBytes != null && Object.hasOwnProperty.call(message, "progressBytes")) + $root.google.datastore.admin.v1.Progress.encode(message.progressBytes, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.entityFilter != null && Object.hasOwnProperty.call(message, "entityFilter")) + $root.google.datastore.admin.v1.EntityFilter.encode(message.entityFilter, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.inputUrl != null && Object.hasOwnProperty.call(message, "inputUrl")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.inputUrl); + return writer; + }; + + /** + * Encodes the specified ImportEntitiesMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ImportEntitiesMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.IImportEntitiesMetadata} message ImportEntitiesMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ImportEntitiesMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ImportEntitiesMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.ImportEntitiesMetadata} ImportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportEntitiesMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.ImportEntitiesMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.datastore.admin.v1.CommonMetadata.decode(reader, reader.uint32()); + break; + } + case 2: { + message.progressEntities = $root.google.datastore.admin.v1.Progress.decode(reader, reader.uint32()); + break; + } + case 3: { + message.progressBytes = $root.google.datastore.admin.v1.Progress.decode(reader, reader.uint32()); + break; + } + case 4: { + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.decode(reader, reader.uint32()); + break; + } + case 5: { + message.inputUrl = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ImportEntitiesMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.ImportEntitiesMetadata} ImportEntitiesMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ImportEntitiesMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ImportEntitiesMetadata message. + * @function verify + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ImportEntitiesMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.datastore.admin.v1.CommonMetadata.verify(message.common); + if (error) + return "common." + error; + } + if (message.progressEntities != null && message.hasOwnProperty("progressEntities")) { + var error = $root.google.datastore.admin.v1.Progress.verify(message.progressEntities); + if (error) + return "progressEntities." + error; + } + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) { + var error = $root.google.datastore.admin.v1.Progress.verify(message.progressBytes); + if (error) + return "progressBytes." + error; + } + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) { + var error = $root.google.datastore.admin.v1.EntityFilter.verify(message.entityFilter); + if (error) + return "entityFilter." + error; + } + if (message.inputUrl != null && message.hasOwnProperty("inputUrl")) + if (!$util.isString(message.inputUrl)) + return "inputUrl: string expected"; + return null; + }; + + /** + * Creates an ImportEntitiesMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.ImportEntitiesMetadata} ImportEntitiesMetadata + */ + ImportEntitiesMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.ImportEntitiesMetadata) + return object; + var message = new $root.google.datastore.admin.v1.ImportEntitiesMetadata(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.datastore.admin.v1.ImportEntitiesMetadata.common: object expected"); + message.common = $root.google.datastore.admin.v1.CommonMetadata.fromObject(object.common); + } + if (object.progressEntities != null) { + if (typeof object.progressEntities !== "object") + throw TypeError(".google.datastore.admin.v1.ImportEntitiesMetadata.progressEntities: object expected"); + message.progressEntities = $root.google.datastore.admin.v1.Progress.fromObject(object.progressEntities); + } + if (object.progressBytes != null) { + if (typeof object.progressBytes !== "object") + throw TypeError(".google.datastore.admin.v1.ImportEntitiesMetadata.progressBytes: object expected"); + message.progressBytes = $root.google.datastore.admin.v1.Progress.fromObject(object.progressBytes); + } + if (object.entityFilter != null) { + if (typeof object.entityFilter !== "object") + throw TypeError(".google.datastore.admin.v1.ImportEntitiesMetadata.entityFilter: object expected"); + message.entityFilter = $root.google.datastore.admin.v1.EntityFilter.fromObject(object.entityFilter); + } + if (object.inputUrl != null) + message.inputUrl = String(object.inputUrl); + return message; + }; + + /** + * Creates a plain object from an ImportEntitiesMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {google.datastore.admin.v1.ImportEntitiesMetadata} message ImportEntitiesMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ImportEntitiesMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.common = null; + object.progressEntities = null; + object.progressBytes = null; + object.entityFilter = null; + object.inputUrl = ""; + } + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.datastore.admin.v1.CommonMetadata.toObject(message.common, options); + if (message.progressEntities != null && message.hasOwnProperty("progressEntities")) + object.progressEntities = $root.google.datastore.admin.v1.Progress.toObject(message.progressEntities, options); + if (message.progressBytes != null && message.hasOwnProperty("progressBytes")) + object.progressBytes = $root.google.datastore.admin.v1.Progress.toObject(message.progressBytes, options); + if (message.entityFilter != null && message.hasOwnProperty("entityFilter")) + object.entityFilter = $root.google.datastore.admin.v1.EntityFilter.toObject(message.entityFilter, options); + if (message.inputUrl != null && message.hasOwnProperty("inputUrl")) + object.inputUrl = message.inputUrl; + return object; + }; + + /** + * Converts this ImportEntitiesMetadata to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @instance + * @returns {Object.} JSON object + */ + ImportEntitiesMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ImportEntitiesMetadata + * @function getTypeUrl + * @memberof google.datastore.admin.v1.ImportEntitiesMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ImportEntitiesMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.ImportEntitiesMetadata"; + }; + + return ImportEntitiesMetadata; + })(); + + v1.EntityFilter = (function() { + + /** + * Properties of an EntityFilter. + * @memberof google.datastore.admin.v1 + * @interface IEntityFilter + * @property {Array.|null} [kinds] EntityFilter kinds + * @property {Array.|null} [namespaceIds] EntityFilter namespaceIds + */ + + /** + * Constructs a new EntityFilter. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an EntityFilter. + * @implements IEntityFilter + * @constructor + * @param {google.datastore.admin.v1.IEntityFilter=} [properties] Properties to set + */ + function EntityFilter(properties) { + this.kinds = []; + this.namespaceIds = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EntityFilter kinds. + * @member {Array.} kinds + * @memberof google.datastore.admin.v1.EntityFilter + * @instance + */ + EntityFilter.prototype.kinds = $util.emptyArray; + + /** + * EntityFilter namespaceIds. + * @member {Array.} namespaceIds + * @memberof google.datastore.admin.v1.EntityFilter + * @instance + */ + EntityFilter.prototype.namespaceIds = $util.emptyArray; + + /** + * Creates a new EntityFilter instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {google.datastore.admin.v1.IEntityFilter=} [properties] Properties to set + * @returns {google.datastore.admin.v1.EntityFilter} EntityFilter instance + */ + EntityFilter.create = function create(properties) { + return new EntityFilter(properties); + }; + + /** + * Encodes the specified EntityFilter message. Does not implicitly {@link google.datastore.admin.v1.EntityFilter.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {google.datastore.admin.v1.IEntityFilter} message EntityFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntityFilter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.kinds != null && message.kinds.length) + for (var i = 0; i < message.kinds.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.kinds[i]); + if (message.namespaceIds != null && message.namespaceIds.length) + for (var i = 0; i < message.namespaceIds.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.namespaceIds[i]); + return writer; + }; + + /** + * Encodes the specified EntityFilter message, length delimited. Does not implicitly {@link google.datastore.admin.v1.EntityFilter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {google.datastore.admin.v1.IEntityFilter} message EntityFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntityFilter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EntityFilter message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.EntityFilter} EntityFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntityFilter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.EntityFilter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.kinds && message.kinds.length)) + message.kinds = []; + message.kinds.push(reader.string()); + break; + } + case 2: { + if (!(message.namespaceIds && message.namespaceIds.length)) + message.namespaceIds = []; + message.namespaceIds.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EntityFilter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.EntityFilter} EntityFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntityFilter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EntityFilter message. + * @function verify + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EntityFilter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.kinds != null && message.hasOwnProperty("kinds")) { + if (!Array.isArray(message.kinds)) + return "kinds: array expected"; + for (var i = 0; i < message.kinds.length; ++i) + if (!$util.isString(message.kinds[i])) + return "kinds: string[] expected"; + } + if (message.namespaceIds != null && message.hasOwnProperty("namespaceIds")) { + if (!Array.isArray(message.namespaceIds)) + return "namespaceIds: array expected"; + for (var i = 0; i < message.namespaceIds.length; ++i) + if (!$util.isString(message.namespaceIds[i])) + return "namespaceIds: string[] expected"; + } + return null; + }; + + /** + * Creates an EntityFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.EntityFilter} EntityFilter + */ + EntityFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.EntityFilter) + return object; + var message = new $root.google.datastore.admin.v1.EntityFilter(); + if (object.kinds) { + if (!Array.isArray(object.kinds)) + throw TypeError(".google.datastore.admin.v1.EntityFilter.kinds: array expected"); + message.kinds = []; + for (var i = 0; i < object.kinds.length; ++i) + message.kinds[i] = String(object.kinds[i]); + } + if (object.namespaceIds) { + if (!Array.isArray(object.namespaceIds)) + throw TypeError(".google.datastore.admin.v1.EntityFilter.namespaceIds: array expected"); + message.namespaceIds = []; + for (var i = 0; i < object.namespaceIds.length; ++i) + message.namespaceIds[i] = String(object.namespaceIds[i]); + } + return message; + }; + + /** + * Creates a plain object from an EntityFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {google.datastore.admin.v1.EntityFilter} message EntityFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EntityFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.kinds = []; + object.namespaceIds = []; + } + if (message.kinds && message.kinds.length) { + object.kinds = []; + for (var j = 0; j < message.kinds.length; ++j) + object.kinds[j] = message.kinds[j]; + } + if (message.namespaceIds && message.namespaceIds.length) { + object.namespaceIds = []; + for (var j = 0; j < message.namespaceIds.length; ++j) + object.namespaceIds[j] = message.namespaceIds[j]; + } + return object; + }; + + /** + * Converts this EntityFilter to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.EntityFilter + * @instance + * @returns {Object.} JSON object + */ + EntityFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EntityFilter + * @function getTypeUrl + * @memberof google.datastore.admin.v1.EntityFilter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EntityFilter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.EntityFilter"; + }; + + return EntityFilter; + })(); + + v1.CreateIndexRequest = (function() { + + /** + * Properties of a CreateIndexRequest. + * @memberof google.datastore.admin.v1 + * @interface ICreateIndexRequest + * @property {string|null} [projectId] CreateIndexRequest projectId + * @property {google.datastore.admin.v1.IIndex|null} [index] CreateIndexRequest index + */ + + /** + * Constructs a new CreateIndexRequest. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a CreateIndexRequest. + * @implements ICreateIndexRequest + * @constructor + * @param {google.datastore.admin.v1.ICreateIndexRequest=} [properties] Properties to set + */ + function CreateIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateIndexRequest projectId. + * @member {string} projectId + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @instance + */ + CreateIndexRequest.prototype.projectId = ""; + + /** + * CreateIndexRequest index. + * @member {google.datastore.admin.v1.IIndex|null|undefined} index + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @instance + */ + CreateIndexRequest.prototype.index = null; + + /** + * Creates a new CreateIndexRequest instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {google.datastore.admin.v1.ICreateIndexRequest=} [properties] Properties to set + * @returns {google.datastore.admin.v1.CreateIndexRequest} CreateIndexRequest instance + */ + CreateIndexRequest.create = function create(properties) { + return new CreateIndexRequest(properties); + }; + + /** + * Encodes the specified CreateIndexRequest message. Does not implicitly {@link google.datastore.admin.v1.CreateIndexRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {google.datastore.admin.v1.ICreateIndexRequest} message CreateIndexRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateIndexRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.projectId); + if (message.index != null && Object.hasOwnProperty.call(message, "index")) + $root.google.datastore.admin.v1.Index.encode(message.index, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateIndexRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.CreateIndexRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {google.datastore.admin.v1.ICreateIndexRequest} message CreateIndexRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateIndexRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateIndexRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.CreateIndexRequest} CreateIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateIndexRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.CreateIndexRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.projectId = reader.string(); + break; + } + case 3: { + message.index = $root.google.datastore.admin.v1.Index.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateIndexRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.CreateIndexRequest} CreateIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateIndexRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateIndexRequest message. + * @function verify + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateIndexRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.index != null && message.hasOwnProperty("index")) { + var error = $root.google.datastore.admin.v1.Index.verify(message.index); + if (error) + return "index." + error; + } + return null; + }; + + /** + * Creates a CreateIndexRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.CreateIndexRequest} CreateIndexRequest + */ + CreateIndexRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.CreateIndexRequest) + return object; + var message = new $root.google.datastore.admin.v1.CreateIndexRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.index != null) { + if (typeof object.index !== "object") + throw TypeError(".google.datastore.admin.v1.CreateIndexRequest.index: object expected"); + message.index = $root.google.datastore.admin.v1.Index.fromObject(object.index); + } + return message; + }; + + /** + * Creates a plain object from a CreateIndexRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {google.datastore.admin.v1.CreateIndexRequest} message CreateIndexRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateIndexRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.projectId = ""; + object.index = null; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.index != null && message.hasOwnProperty("index")) + object.index = $root.google.datastore.admin.v1.Index.toObject(message.index, options); + return object; + }; + + /** + * Converts this CreateIndexRequest to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @instance + * @returns {Object.} JSON object + */ + CreateIndexRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateIndexRequest + * @function getTypeUrl + * @memberof google.datastore.admin.v1.CreateIndexRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateIndexRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.CreateIndexRequest"; + }; + + return CreateIndexRequest; + })(); + + v1.DeleteIndexRequest = (function() { + + /** + * Properties of a DeleteIndexRequest. + * @memberof google.datastore.admin.v1 + * @interface IDeleteIndexRequest + * @property {string|null} [projectId] DeleteIndexRequest projectId + * @property {string|null} [indexId] DeleteIndexRequest indexId + */ + + /** + * Constructs a new DeleteIndexRequest. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a DeleteIndexRequest. + * @implements IDeleteIndexRequest + * @constructor + * @param {google.datastore.admin.v1.IDeleteIndexRequest=} [properties] Properties to set + */ + function DeleteIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteIndexRequest projectId. + * @member {string} projectId + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @instance + */ + DeleteIndexRequest.prototype.projectId = ""; + + /** + * DeleteIndexRequest indexId. + * @member {string} indexId + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @instance + */ + DeleteIndexRequest.prototype.indexId = ""; + + /** + * Creates a new DeleteIndexRequest instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {google.datastore.admin.v1.IDeleteIndexRequest=} [properties] Properties to set + * @returns {google.datastore.admin.v1.DeleteIndexRequest} DeleteIndexRequest instance + */ + DeleteIndexRequest.create = function create(properties) { + return new DeleteIndexRequest(properties); + }; + + /** + * Encodes the specified DeleteIndexRequest message. Does not implicitly {@link google.datastore.admin.v1.DeleteIndexRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {google.datastore.admin.v1.IDeleteIndexRequest} message DeleteIndexRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteIndexRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.projectId); + if (message.indexId != null && Object.hasOwnProperty.call(message, "indexId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.indexId); + return writer; + }; + + /** + * Encodes the specified DeleteIndexRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.DeleteIndexRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {google.datastore.admin.v1.IDeleteIndexRequest} message DeleteIndexRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteIndexRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteIndexRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.DeleteIndexRequest} DeleteIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteIndexRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.DeleteIndexRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.projectId = reader.string(); + break; + } + case 3: { + message.indexId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteIndexRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.DeleteIndexRequest} DeleteIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteIndexRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteIndexRequest message. + * @function verify + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteIndexRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.indexId != null && message.hasOwnProperty("indexId")) + if (!$util.isString(message.indexId)) + return "indexId: string expected"; + return null; + }; + + /** + * Creates a DeleteIndexRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.DeleteIndexRequest} DeleteIndexRequest + */ + DeleteIndexRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.DeleteIndexRequest) + return object; + var message = new $root.google.datastore.admin.v1.DeleteIndexRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.indexId != null) + message.indexId = String(object.indexId); + return message; + }; + + /** + * Creates a plain object from a DeleteIndexRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {google.datastore.admin.v1.DeleteIndexRequest} message DeleteIndexRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteIndexRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.projectId = ""; + object.indexId = ""; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.indexId != null && message.hasOwnProperty("indexId")) + object.indexId = message.indexId; + return object; + }; + + /** + * Converts this DeleteIndexRequest to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteIndexRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteIndexRequest + * @function getTypeUrl + * @memberof google.datastore.admin.v1.DeleteIndexRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteIndexRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.DeleteIndexRequest"; + }; + + return DeleteIndexRequest; + })(); + + v1.GetIndexRequest = (function() { + + /** + * Properties of a GetIndexRequest. + * @memberof google.datastore.admin.v1 + * @interface IGetIndexRequest + * @property {string|null} [projectId] GetIndexRequest projectId + * @property {string|null} [indexId] GetIndexRequest indexId + */ + + /** + * Constructs a new GetIndexRequest. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a GetIndexRequest. + * @implements IGetIndexRequest + * @constructor + * @param {google.datastore.admin.v1.IGetIndexRequest=} [properties] Properties to set + */ + function GetIndexRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetIndexRequest projectId. + * @member {string} projectId + * @memberof google.datastore.admin.v1.GetIndexRequest + * @instance + */ + GetIndexRequest.prototype.projectId = ""; + + /** + * GetIndexRequest indexId. + * @member {string} indexId + * @memberof google.datastore.admin.v1.GetIndexRequest + * @instance + */ + GetIndexRequest.prototype.indexId = ""; + + /** + * Creates a new GetIndexRequest instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {google.datastore.admin.v1.IGetIndexRequest=} [properties] Properties to set + * @returns {google.datastore.admin.v1.GetIndexRequest} GetIndexRequest instance + */ + GetIndexRequest.create = function create(properties) { + return new GetIndexRequest(properties); + }; + + /** + * Encodes the specified GetIndexRequest message. Does not implicitly {@link google.datastore.admin.v1.GetIndexRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {google.datastore.admin.v1.IGetIndexRequest} message GetIndexRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetIndexRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.projectId); + if (message.indexId != null && Object.hasOwnProperty.call(message, "indexId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.indexId); + return writer; + }; + + /** + * Encodes the specified GetIndexRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.GetIndexRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {google.datastore.admin.v1.IGetIndexRequest} message GetIndexRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetIndexRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetIndexRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.GetIndexRequest} GetIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetIndexRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.GetIndexRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.projectId = reader.string(); + break; + } + case 3: { + message.indexId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetIndexRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.GetIndexRequest} GetIndexRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetIndexRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetIndexRequest message. + * @function verify + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetIndexRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.indexId != null && message.hasOwnProperty("indexId")) + if (!$util.isString(message.indexId)) + return "indexId: string expected"; + return null; + }; + + /** + * Creates a GetIndexRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.GetIndexRequest} GetIndexRequest + */ + GetIndexRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.GetIndexRequest) + return object; + var message = new $root.google.datastore.admin.v1.GetIndexRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.indexId != null) + message.indexId = String(object.indexId); + return message; + }; + + /** + * Creates a plain object from a GetIndexRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {google.datastore.admin.v1.GetIndexRequest} message GetIndexRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetIndexRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.projectId = ""; + object.indexId = ""; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.indexId != null && message.hasOwnProperty("indexId")) + object.indexId = message.indexId; + return object; + }; + + /** + * Converts this GetIndexRequest to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.GetIndexRequest + * @instance + * @returns {Object.} JSON object + */ + GetIndexRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetIndexRequest + * @function getTypeUrl + * @memberof google.datastore.admin.v1.GetIndexRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetIndexRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.GetIndexRequest"; + }; + + return GetIndexRequest; + })(); + + v1.ListIndexesRequest = (function() { + + /** + * Properties of a ListIndexesRequest. + * @memberof google.datastore.admin.v1 + * @interface IListIndexesRequest + * @property {string|null} [projectId] ListIndexesRequest projectId + * @property {string|null} [filter] ListIndexesRequest filter + * @property {number|null} [pageSize] ListIndexesRequest pageSize + * @property {string|null} [pageToken] ListIndexesRequest pageToken + */ + + /** + * Constructs a new ListIndexesRequest. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a ListIndexesRequest. + * @implements IListIndexesRequest + * @constructor + * @param {google.datastore.admin.v1.IListIndexesRequest=} [properties] Properties to set + */ + function ListIndexesRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListIndexesRequest projectId. + * @member {string} projectId + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.projectId = ""; + + /** + * ListIndexesRequest filter. + * @member {string} filter + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.filter = ""; + + /** + * ListIndexesRequest pageSize. + * @member {number} pageSize + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.pageSize = 0; + + /** + * ListIndexesRequest pageToken. + * @member {string} pageToken + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @instance + */ + ListIndexesRequest.prototype.pageToken = ""; + + /** + * Creates a new ListIndexesRequest instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {google.datastore.admin.v1.IListIndexesRequest=} [properties] Properties to set + * @returns {google.datastore.admin.v1.ListIndexesRequest} ListIndexesRequest instance + */ + ListIndexesRequest.create = function create(properties) { + return new ListIndexesRequest(properties); + }; + + /** + * Encodes the specified ListIndexesRequest message. Does not implicitly {@link google.datastore.admin.v1.ListIndexesRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {google.datastore.admin.v1.IListIndexesRequest} message ListIndexesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListIndexesRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.projectId); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.filter); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.pageToken); + return writer; + }; + + /** + * Encodes the specified ListIndexesRequest message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ListIndexesRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {google.datastore.admin.v1.IListIndexesRequest} message ListIndexesRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListIndexesRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListIndexesRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.ListIndexesRequest} ListIndexesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListIndexesRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.ListIndexesRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.projectId = reader.string(); + break; + } + case 3: { + message.filter = reader.string(); + break; + } + case 4: { + message.pageSize = reader.int32(); + break; + } + case 5: { + message.pageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListIndexesRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.ListIndexesRequest} ListIndexesRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListIndexesRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListIndexesRequest message. + * @function verify + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListIndexesRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListIndexesRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.ListIndexesRequest} ListIndexesRequest + */ + ListIndexesRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.ListIndexesRequest) + return object; + var message = new $root.google.datastore.admin.v1.ListIndexesRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListIndexesRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {google.datastore.admin.v1.ListIndexesRequest} message ListIndexesRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListIndexesRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.projectId = ""; + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + return object; + }; + + /** + * Converts this ListIndexesRequest to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @instance + * @returns {Object.} JSON object + */ + ListIndexesRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListIndexesRequest + * @function getTypeUrl + * @memberof google.datastore.admin.v1.ListIndexesRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListIndexesRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.ListIndexesRequest"; + }; + + return ListIndexesRequest; + })(); + + v1.ListIndexesResponse = (function() { + + /** + * Properties of a ListIndexesResponse. + * @memberof google.datastore.admin.v1 + * @interface IListIndexesResponse + * @property {Array.|null} [indexes] ListIndexesResponse indexes + * @property {string|null} [nextPageToken] ListIndexesResponse nextPageToken + */ + + /** + * Constructs a new ListIndexesResponse. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a ListIndexesResponse. + * @implements IListIndexesResponse + * @constructor + * @param {google.datastore.admin.v1.IListIndexesResponse=} [properties] Properties to set + */ + function ListIndexesResponse(properties) { + this.indexes = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListIndexesResponse indexes. + * @member {Array.} indexes + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @instance + */ + ListIndexesResponse.prototype.indexes = $util.emptyArray; + + /** + * ListIndexesResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @instance + */ + ListIndexesResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListIndexesResponse instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {google.datastore.admin.v1.IListIndexesResponse=} [properties] Properties to set + * @returns {google.datastore.admin.v1.ListIndexesResponse} ListIndexesResponse instance + */ + ListIndexesResponse.create = function create(properties) { + return new ListIndexesResponse(properties); + }; + + /** + * Encodes the specified ListIndexesResponse message. Does not implicitly {@link google.datastore.admin.v1.ListIndexesResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {google.datastore.admin.v1.IListIndexesResponse} message ListIndexesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListIndexesResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.indexes != null && message.indexes.length) + for (var i = 0; i < message.indexes.length; ++i) + $root.google.datastore.admin.v1.Index.encode(message.indexes[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListIndexesResponse message, length delimited. Does not implicitly {@link google.datastore.admin.v1.ListIndexesResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {google.datastore.admin.v1.IListIndexesResponse} message ListIndexesResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListIndexesResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListIndexesResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.ListIndexesResponse} ListIndexesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListIndexesResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.ListIndexesResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.indexes && message.indexes.length)) + message.indexes = []; + message.indexes.push($root.google.datastore.admin.v1.Index.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListIndexesResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.ListIndexesResponse} ListIndexesResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListIndexesResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListIndexesResponse message. + * @function verify + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListIndexesResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.indexes != null && message.hasOwnProperty("indexes")) { + if (!Array.isArray(message.indexes)) + return "indexes: array expected"; + for (var i = 0; i < message.indexes.length; ++i) { + var error = $root.google.datastore.admin.v1.Index.verify(message.indexes[i]); + if (error) + return "indexes." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListIndexesResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.ListIndexesResponse} ListIndexesResponse + */ + ListIndexesResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.ListIndexesResponse) + return object; + var message = new $root.google.datastore.admin.v1.ListIndexesResponse(); + if (object.indexes) { + if (!Array.isArray(object.indexes)) + throw TypeError(".google.datastore.admin.v1.ListIndexesResponse.indexes: array expected"); + message.indexes = []; + for (var i = 0; i < object.indexes.length; ++i) { + if (typeof object.indexes[i] !== "object") + throw TypeError(".google.datastore.admin.v1.ListIndexesResponse.indexes: object expected"); + message.indexes[i] = $root.google.datastore.admin.v1.Index.fromObject(object.indexes[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListIndexesResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {google.datastore.admin.v1.ListIndexesResponse} message ListIndexesResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListIndexesResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.indexes = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.indexes && message.indexes.length) { + object.indexes = []; + for (var j = 0; j < message.indexes.length; ++j) + object.indexes[j] = $root.google.datastore.admin.v1.Index.toObject(message.indexes[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListIndexesResponse to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @instance + * @returns {Object.} JSON object + */ + ListIndexesResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListIndexesResponse + * @function getTypeUrl + * @memberof google.datastore.admin.v1.ListIndexesResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListIndexesResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.ListIndexesResponse"; + }; + + return ListIndexesResponse; + })(); + + v1.IndexOperationMetadata = (function() { + + /** + * Properties of an IndexOperationMetadata. + * @memberof google.datastore.admin.v1 + * @interface IIndexOperationMetadata + * @property {google.datastore.admin.v1.ICommonMetadata|null} [common] IndexOperationMetadata common + * @property {google.datastore.admin.v1.IProgress|null} [progressEntities] IndexOperationMetadata progressEntities + * @property {string|null} [indexId] IndexOperationMetadata indexId + */ + + /** + * Constructs a new IndexOperationMetadata. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an IndexOperationMetadata. + * @implements IIndexOperationMetadata + * @constructor + * @param {google.datastore.admin.v1.IIndexOperationMetadata=} [properties] Properties to set + */ + function IndexOperationMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexOperationMetadata common. + * @member {google.datastore.admin.v1.ICommonMetadata|null|undefined} common + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.common = null; + + /** + * IndexOperationMetadata progressEntities. + * @member {google.datastore.admin.v1.IProgress|null|undefined} progressEntities + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.progressEntities = null; + + /** + * IndexOperationMetadata indexId. + * @member {string} indexId + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @instance + */ + IndexOperationMetadata.prototype.indexId = ""; + + /** + * Creates a new IndexOperationMetadata instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {google.datastore.admin.v1.IIndexOperationMetadata=} [properties] Properties to set + * @returns {google.datastore.admin.v1.IndexOperationMetadata} IndexOperationMetadata instance + */ + IndexOperationMetadata.create = function create(properties) { + return new IndexOperationMetadata(properties); + }; + + /** + * Encodes the specified IndexOperationMetadata message. Does not implicitly {@link google.datastore.admin.v1.IndexOperationMetadata.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {google.datastore.admin.v1.IIndexOperationMetadata} message IndexOperationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IndexOperationMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.datastore.admin.v1.CommonMetadata.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.progressEntities != null && Object.hasOwnProperty.call(message, "progressEntities")) + $root.google.datastore.admin.v1.Progress.encode(message.progressEntities, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.indexId != null && Object.hasOwnProperty.call(message, "indexId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.indexId); + return writer; + }; + + /** + * Encodes the specified IndexOperationMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.IndexOperationMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {google.datastore.admin.v1.IIndexOperationMetadata} message IndexOperationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IndexOperationMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an IndexOperationMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.IndexOperationMetadata} IndexOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IndexOperationMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.IndexOperationMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.datastore.admin.v1.CommonMetadata.decode(reader, reader.uint32()); + break; + } + case 2: { + message.progressEntities = $root.google.datastore.admin.v1.Progress.decode(reader, reader.uint32()); + break; + } + case 3: { + message.indexId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an IndexOperationMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.IndexOperationMetadata} IndexOperationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IndexOperationMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an IndexOperationMetadata message. + * @function verify + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + IndexOperationMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.datastore.admin.v1.CommonMetadata.verify(message.common); + if (error) + return "common." + error; + } + if (message.progressEntities != null && message.hasOwnProperty("progressEntities")) { + var error = $root.google.datastore.admin.v1.Progress.verify(message.progressEntities); + if (error) + return "progressEntities." + error; + } + if (message.indexId != null && message.hasOwnProperty("indexId")) + if (!$util.isString(message.indexId)) + return "indexId: string expected"; + return null; + }; + + /** + * Creates an IndexOperationMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.IndexOperationMetadata} IndexOperationMetadata + */ + IndexOperationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.IndexOperationMetadata) + return object; + var message = new $root.google.datastore.admin.v1.IndexOperationMetadata(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.datastore.admin.v1.IndexOperationMetadata.common: object expected"); + message.common = $root.google.datastore.admin.v1.CommonMetadata.fromObject(object.common); + } + if (object.progressEntities != null) { + if (typeof object.progressEntities !== "object") + throw TypeError(".google.datastore.admin.v1.IndexOperationMetadata.progressEntities: object expected"); + message.progressEntities = $root.google.datastore.admin.v1.Progress.fromObject(object.progressEntities); + } + if (object.indexId != null) + message.indexId = String(object.indexId); + return message; + }; + + /** + * Creates a plain object from an IndexOperationMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {google.datastore.admin.v1.IndexOperationMetadata} message IndexOperationMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IndexOperationMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.common = null; + object.progressEntities = null; + object.indexId = ""; + } + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.datastore.admin.v1.CommonMetadata.toObject(message.common, options); + if (message.progressEntities != null && message.hasOwnProperty("progressEntities")) + object.progressEntities = $root.google.datastore.admin.v1.Progress.toObject(message.progressEntities, options); + if (message.indexId != null && message.hasOwnProperty("indexId")) + object.indexId = message.indexId; + return object; + }; + + /** + * Converts this IndexOperationMetadata to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @instance + * @returns {Object.} JSON object + */ + IndexOperationMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for IndexOperationMetadata + * @function getTypeUrl + * @memberof google.datastore.admin.v1.IndexOperationMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + IndexOperationMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.IndexOperationMetadata"; + }; + + return IndexOperationMetadata; + })(); + + v1.DatastoreFirestoreMigrationMetadata = (function() { + + /** + * Properties of a DatastoreFirestoreMigrationMetadata. + * @memberof google.datastore.admin.v1 + * @interface IDatastoreFirestoreMigrationMetadata + * @property {google.datastore.admin.v1.MigrationState|null} [migrationState] DatastoreFirestoreMigrationMetadata migrationState + * @property {google.datastore.admin.v1.MigrationStep|null} [migrationStep] DatastoreFirestoreMigrationMetadata migrationStep + */ + + /** + * Constructs a new DatastoreFirestoreMigrationMetadata. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a DatastoreFirestoreMigrationMetadata. + * @implements IDatastoreFirestoreMigrationMetadata + * @constructor + * @param {google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata=} [properties] Properties to set + */ + function DatastoreFirestoreMigrationMetadata(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DatastoreFirestoreMigrationMetadata migrationState. + * @member {google.datastore.admin.v1.MigrationState} migrationState + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @instance + */ + DatastoreFirestoreMigrationMetadata.prototype.migrationState = 0; + + /** + * DatastoreFirestoreMigrationMetadata migrationStep. + * @member {google.datastore.admin.v1.MigrationStep} migrationStep + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @instance + */ + DatastoreFirestoreMigrationMetadata.prototype.migrationStep = 0; + + /** + * Creates a new DatastoreFirestoreMigrationMetadata instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata=} [properties] Properties to set + * @returns {google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata} DatastoreFirestoreMigrationMetadata instance + */ + DatastoreFirestoreMigrationMetadata.create = function create(properties) { + return new DatastoreFirestoreMigrationMetadata(properties); + }; + + /** + * Encodes the specified DatastoreFirestoreMigrationMetadata message. Does not implicitly {@link google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata} message DatastoreFirestoreMigrationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DatastoreFirestoreMigrationMetadata.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.migrationState != null && Object.hasOwnProperty.call(message, "migrationState")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.migrationState); + if (message.migrationStep != null && Object.hasOwnProperty.call(message, "migrationStep")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.migrationStep); + return writer; + }; + + /** + * Encodes the specified DatastoreFirestoreMigrationMetadata message, length delimited. Does not implicitly {@link google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {google.datastore.admin.v1.IDatastoreFirestoreMigrationMetadata} message DatastoreFirestoreMigrationMetadata message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DatastoreFirestoreMigrationMetadata.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DatastoreFirestoreMigrationMetadata message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata} DatastoreFirestoreMigrationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DatastoreFirestoreMigrationMetadata.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.migrationState = reader.int32(); + break; + } + case 2: { + message.migrationStep = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DatastoreFirestoreMigrationMetadata message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata} DatastoreFirestoreMigrationMetadata + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DatastoreFirestoreMigrationMetadata.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DatastoreFirestoreMigrationMetadata message. + * @function verify + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DatastoreFirestoreMigrationMetadata.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.migrationState != null && message.hasOwnProperty("migrationState")) + switch (message.migrationState) { + default: + return "migrationState: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.migrationStep != null && message.hasOwnProperty("migrationStep")) + switch (message.migrationStep) { + default: + return "migrationStep: enum value expected"; + case 0: + case 6: + case 1: + case 7: + case 2: + case 3: + case 4: + case 5: + break; + } + return null; + }; + + /** + * Creates a DatastoreFirestoreMigrationMetadata message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata} DatastoreFirestoreMigrationMetadata + */ + DatastoreFirestoreMigrationMetadata.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) + return object; + var message = new $root.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata(); + switch (object.migrationState) { + default: + if (typeof object.migrationState === "number") { + message.migrationState = object.migrationState; + break; + } + break; + case "MIGRATION_STATE_UNSPECIFIED": + case 0: + message.migrationState = 0; + break; + case "RUNNING": + case 1: + message.migrationState = 1; + break; + case "PAUSED": + case 2: + message.migrationState = 2; + break; + case "COMPLETE": + case 3: + message.migrationState = 3; + break; + } + switch (object.migrationStep) { + default: + if (typeof object.migrationStep === "number") { + message.migrationStep = object.migrationStep; + break; + } + break; + case "MIGRATION_STEP_UNSPECIFIED": + case 0: + message.migrationStep = 0; + break; + case "PREPARE": + case 6: + message.migrationStep = 6; + break; + case "START": + case 1: + message.migrationStep = 1; + break; + case "APPLY_WRITES_SYNCHRONOUSLY": + case 7: + message.migrationStep = 7; + break; + case "COPY_AND_VERIFY": + case 2: + message.migrationStep = 2; + break; + case "REDIRECT_EVENTUALLY_CONSISTENT_READS": + case 3: + message.migrationStep = 3; + break; + case "REDIRECT_STRONGLY_CONSISTENT_READS": + case 4: + message.migrationStep = 4; + break; + case "REDIRECT_WRITES": + case 5: + message.migrationStep = 5; + break; + } + return message; + }; + + /** + * Creates a plain object from a DatastoreFirestoreMigrationMetadata message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata} message DatastoreFirestoreMigrationMetadata + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DatastoreFirestoreMigrationMetadata.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.migrationState = options.enums === String ? "MIGRATION_STATE_UNSPECIFIED" : 0; + object.migrationStep = options.enums === String ? "MIGRATION_STEP_UNSPECIFIED" : 0; + } + if (message.migrationState != null && message.hasOwnProperty("migrationState")) + object.migrationState = options.enums === String ? $root.google.datastore.admin.v1.MigrationState[message.migrationState] === undefined ? message.migrationState : $root.google.datastore.admin.v1.MigrationState[message.migrationState] : message.migrationState; + if (message.migrationStep != null && message.hasOwnProperty("migrationStep")) + object.migrationStep = options.enums === String ? $root.google.datastore.admin.v1.MigrationStep[message.migrationStep] === undefined ? message.migrationStep : $root.google.datastore.admin.v1.MigrationStep[message.migrationStep] : message.migrationStep; + return object; + }; + + /** + * Converts this DatastoreFirestoreMigrationMetadata to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @instance + * @returns {Object.} JSON object + */ + DatastoreFirestoreMigrationMetadata.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DatastoreFirestoreMigrationMetadata + * @function getTypeUrl + * @memberof google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DatastoreFirestoreMigrationMetadata.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata"; + }; + + return DatastoreFirestoreMigrationMetadata; + })(); + + /** + * OperationType enum. + * @name google.datastore.admin.v1.OperationType + * @enum {number} + * @property {number} OPERATION_TYPE_UNSPECIFIED=0 OPERATION_TYPE_UNSPECIFIED value + * @property {number} EXPORT_ENTITIES=1 EXPORT_ENTITIES value + * @property {number} IMPORT_ENTITIES=2 IMPORT_ENTITIES value + * @property {number} CREATE_INDEX=3 CREATE_INDEX value + * @property {number} DELETE_INDEX=4 DELETE_INDEX value + */ + v1.OperationType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATION_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "EXPORT_ENTITIES"] = 1; + values[valuesById[2] = "IMPORT_ENTITIES"] = 2; + values[valuesById[3] = "CREATE_INDEX"] = 3; + values[valuesById[4] = "DELETE_INDEX"] = 4; + return values; + })(); + + v1.Index = (function() { + + /** + * Properties of an Index. + * @memberof google.datastore.admin.v1 + * @interface IIndex + * @property {string|null} [projectId] Index projectId + * @property {string|null} [indexId] Index indexId + * @property {string|null} [kind] Index kind + * @property {google.datastore.admin.v1.Index.AncestorMode|null} [ancestor] Index ancestor + * @property {Array.|null} [properties] Index properties + * @property {google.datastore.admin.v1.Index.State|null} [state] Index state + */ + + /** + * Constructs a new Index. + * @memberof google.datastore.admin.v1 + * @classdesc Represents an Index. + * @implements IIndex + * @constructor + * @param {google.datastore.admin.v1.IIndex=} [properties] Properties to set + */ + function Index(properties) { + this.properties = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Index projectId. + * @member {string} projectId + * @memberof google.datastore.admin.v1.Index + * @instance + */ + Index.prototype.projectId = ""; + + /** + * Index indexId. + * @member {string} indexId + * @memberof google.datastore.admin.v1.Index + * @instance + */ + Index.prototype.indexId = ""; + + /** + * Index kind. + * @member {string} kind + * @memberof google.datastore.admin.v1.Index + * @instance + */ + Index.prototype.kind = ""; + + /** + * Index ancestor. + * @member {google.datastore.admin.v1.Index.AncestorMode} ancestor + * @memberof google.datastore.admin.v1.Index + * @instance + */ + Index.prototype.ancestor = 0; + + /** + * Index properties. + * @member {Array.} properties + * @memberof google.datastore.admin.v1.Index + * @instance + */ + Index.prototype.properties = $util.emptyArray; + + /** + * Index state. + * @member {google.datastore.admin.v1.Index.State} state + * @memberof google.datastore.admin.v1.Index + * @instance + */ + Index.prototype.state = 0; + + /** + * Creates a new Index instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.Index + * @static + * @param {google.datastore.admin.v1.IIndex=} [properties] Properties to set + * @returns {google.datastore.admin.v1.Index} Index instance + */ + Index.create = function create(properties) { + return new Index(properties); + }; + + /** + * Encodes the specified Index message. Does not implicitly {@link google.datastore.admin.v1.Index.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.Index + * @static + * @param {google.datastore.admin.v1.IIndex} message Index message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Index.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.projectId); + if (message.indexId != null && Object.hasOwnProperty.call(message, "indexId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.indexId); + if (message.kind != null && Object.hasOwnProperty.call(message, "kind")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.kind); + if (message.ancestor != null && Object.hasOwnProperty.call(message, "ancestor")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.ancestor); + if (message.properties != null && message.properties.length) + for (var i = 0; i < message.properties.length; ++i) + $root.google.datastore.admin.v1.Index.IndexedProperty.encode(message.properties[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.state); + return writer; + }; + + /** + * Encodes the specified Index message, length delimited. Does not implicitly {@link google.datastore.admin.v1.Index.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.Index + * @static + * @param {google.datastore.admin.v1.IIndex} message Index message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Index.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Index message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.Index + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.Index} Index + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Index.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.Index(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.projectId = reader.string(); + break; + } + case 3: { + message.indexId = reader.string(); + break; + } + case 4: { + message.kind = reader.string(); + break; + } + case 5: { + message.ancestor = reader.int32(); + break; + } + case 6: { + if (!(message.properties && message.properties.length)) + message.properties = []; + message.properties.push($root.google.datastore.admin.v1.Index.IndexedProperty.decode(reader, reader.uint32())); + break; + } + case 7: { + message.state = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Index message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.Index + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.Index} Index + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Index.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Index message. + * @function verify + * @memberof google.datastore.admin.v1.Index + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Index.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.indexId != null && message.hasOwnProperty("indexId")) + if (!$util.isString(message.indexId)) + return "indexId: string expected"; + if (message.kind != null && message.hasOwnProperty("kind")) + if (!$util.isString(message.kind)) + return "kind: string expected"; + if (message.ancestor != null && message.hasOwnProperty("ancestor")) + switch (message.ancestor) { + default: + return "ancestor: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.properties != null && message.hasOwnProperty("properties")) { + if (!Array.isArray(message.properties)) + return "properties: array expected"; + for (var i = 0; i < message.properties.length; ++i) { + var error = $root.google.datastore.admin.v1.Index.IndexedProperty.verify(message.properties[i]); + if (error) + return "properties." + error; + } + } + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates an Index message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.Index + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.Index} Index + */ + Index.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.Index) + return object; + var message = new $root.google.datastore.admin.v1.Index(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.indexId != null) + message.indexId = String(object.indexId); + if (object.kind != null) + message.kind = String(object.kind); + switch (object.ancestor) { + default: + if (typeof object.ancestor === "number") { + message.ancestor = object.ancestor; + break; + } + break; + case "ANCESTOR_MODE_UNSPECIFIED": + case 0: + message.ancestor = 0; + break; + case "NONE": + case 1: + message.ancestor = 1; + break; + case "ALL_ANCESTORS": + case 2: + message.ancestor = 2; + break; + } + if (object.properties) { + if (!Array.isArray(object.properties)) + throw TypeError(".google.datastore.admin.v1.Index.properties: array expected"); + message.properties = []; + for (var i = 0; i < object.properties.length; ++i) { + if (typeof object.properties[i] !== "object") + throw TypeError(".google.datastore.admin.v1.Index.properties: object expected"); + message.properties[i] = $root.google.datastore.admin.v1.Index.IndexedProperty.fromObject(object.properties[i]); + } + } + switch (object.state) { + default: + if (typeof object.state === "number") { + message.state = object.state; + break; + } + break; + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "CREATING": + case 1: + message.state = 1; + break; + case "READY": + case 2: + message.state = 2; + break; + case "DELETING": + case 3: + message.state = 3; + break; + case "ERROR": + case 4: + message.state = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from an Index message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.Index + * @static + * @param {google.datastore.admin.v1.Index} message Index + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Index.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.properties = []; + if (options.defaults) { + object.projectId = ""; + object.indexId = ""; + object.kind = ""; + object.ancestor = options.enums === String ? "ANCESTOR_MODE_UNSPECIFIED" : 0; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.indexId != null && message.hasOwnProperty("indexId")) + object.indexId = message.indexId; + if (message.kind != null && message.hasOwnProperty("kind")) + object.kind = message.kind; + if (message.ancestor != null && message.hasOwnProperty("ancestor")) + object.ancestor = options.enums === String ? $root.google.datastore.admin.v1.Index.AncestorMode[message.ancestor] === undefined ? message.ancestor : $root.google.datastore.admin.v1.Index.AncestorMode[message.ancestor] : message.ancestor; + if (message.properties && message.properties.length) { + object.properties = []; + for (var j = 0; j < message.properties.length; ++j) + object.properties[j] = $root.google.datastore.admin.v1.Index.IndexedProperty.toObject(message.properties[j], options); + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.datastore.admin.v1.Index.State[message.state] === undefined ? message.state : $root.google.datastore.admin.v1.Index.State[message.state] : message.state; + return object; + }; + + /** + * Converts this Index to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.Index + * @instance + * @returns {Object.} JSON object + */ + Index.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Index + * @function getTypeUrl + * @memberof google.datastore.admin.v1.Index + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Index.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.Index"; + }; + + /** + * AncestorMode enum. + * @name google.datastore.admin.v1.Index.AncestorMode + * @enum {number} + * @property {number} ANCESTOR_MODE_UNSPECIFIED=0 ANCESTOR_MODE_UNSPECIFIED value + * @property {number} NONE=1 NONE value + * @property {number} ALL_ANCESTORS=2 ALL_ANCESTORS value + */ + Index.AncestorMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ANCESTOR_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "NONE"] = 1; + values[valuesById[2] = "ALL_ANCESTORS"] = 2; + return values; + })(); + + /** + * Direction enum. + * @name google.datastore.admin.v1.Index.Direction + * @enum {number} + * @property {number} DIRECTION_UNSPECIFIED=0 DIRECTION_UNSPECIFIED value + * @property {number} ASCENDING=1 ASCENDING value + * @property {number} DESCENDING=2 DESCENDING value + */ + Index.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "ASCENDING"] = 1; + values[valuesById[2] = "DESCENDING"] = 2; + return values; + })(); + + Index.IndexedProperty = (function() { + + /** + * Properties of an IndexedProperty. + * @memberof google.datastore.admin.v1.Index + * @interface IIndexedProperty + * @property {string|null} [name] IndexedProperty name + * @property {google.datastore.admin.v1.Index.Direction|null} [direction] IndexedProperty direction + */ + + /** + * Constructs a new IndexedProperty. + * @memberof google.datastore.admin.v1.Index + * @classdesc Represents an IndexedProperty. + * @implements IIndexedProperty + * @constructor + * @param {google.datastore.admin.v1.Index.IIndexedProperty=} [properties] Properties to set + */ + function IndexedProperty(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * IndexedProperty name. + * @member {string} name + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @instance + */ + IndexedProperty.prototype.name = ""; + + /** + * IndexedProperty direction. + * @member {google.datastore.admin.v1.Index.Direction} direction + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @instance + */ + IndexedProperty.prototype.direction = 0; + + /** + * Creates a new IndexedProperty instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {google.datastore.admin.v1.Index.IIndexedProperty=} [properties] Properties to set + * @returns {google.datastore.admin.v1.Index.IndexedProperty} IndexedProperty instance + */ + IndexedProperty.create = function create(properties) { + return new IndexedProperty(properties); + }; + + /** + * Encodes the specified IndexedProperty message. Does not implicitly {@link google.datastore.admin.v1.Index.IndexedProperty.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {google.datastore.admin.v1.Index.IIndexedProperty} message IndexedProperty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IndexedProperty.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.direction != null && Object.hasOwnProperty.call(message, "direction")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.direction); + return writer; + }; + + /** + * Encodes the specified IndexedProperty message, length delimited. Does not implicitly {@link google.datastore.admin.v1.Index.IndexedProperty.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {google.datastore.admin.v1.Index.IIndexedProperty} message IndexedProperty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + IndexedProperty.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an IndexedProperty message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.Index.IndexedProperty} IndexedProperty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IndexedProperty.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.Index.IndexedProperty(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.direction = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an IndexedProperty message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.Index.IndexedProperty} IndexedProperty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + IndexedProperty.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an IndexedProperty message. + * @function verify + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + IndexedProperty.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.direction != null && message.hasOwnProperty("direction")) + switch (message.direction) { + default: + return "direction: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates an IndexedProperty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.Index.IndexedProperty} IndexedProperty + */ + IndexedProperty.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.Index.IndexedProperty) + return object; + var message = new $root.google.datastore.admin.v1.Index.IndexedProperty(); + if (object.name != null) + message.name = String(object.name); + switch (object.direction) { + default: + if (typeof object.direction === "number") { + message.direction = object.direction; + break; + } + break; + case "DIRECTION_UNSPECIFIED": + case 0: + message.direction = 0; + break; + case "ASCENDING": + case 1: + message.direction = 1; + break; + case "DESCENDING": + case 2: + message.direction = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an IndexedProperty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {google.datastore.admin.v1.Index.IndexedProperty} message IndexedProperty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + IndexedProperty.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.direction != null && message.hasOwnProperty("direction")) + object.direction = options.enums === String ? $root.google.datastore.admin.v1.Index.Direction[message.direction] === undefined ? message.direction : $root.google.datastore.admin.v1.Index.Direction[message.direction] : message.direction; + return object; + }; + + /** + * Converts this IndexedProperty to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @instance + * @returns {Object.} JSON object + */ + IndexedProperty.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for IndexedProperty + * @function getTypeUrl + * @memberof google.datastore.admin.v1.Index.IndexedProperty + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + IndexedProperty.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.Index.IndexedProperty"; + }; + + return IndexedProperty; + })(); + + /** + * State enum. + * @name google.datastore.admin.v1.Index.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} CREATING=1 CREATING value + * @property {number} READY=2 READY value + * @property {number} DELETING=3 DELETING value + * @property {number} ERROR=4 ERROR value + */ + Index.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "CREATING"] = 1; + values[valuesById[2] = "READY"] = 2; + values[valuesById[3] = "DELETING"] = 3; + values[valuesById[4] = "ERROR"] = 4; + return values; + })(); + + return Index; + })(); + + v1.MigrationStateEvent = (function() { + + /** + * Properties of a MigrationStateEvent. + * @memberof google.datastore.admin.v1 + * @interface IMigrationStateEvent + * @property {google.datastore.admin.v1.MigrationState|null} [state] MigrationStateEvent state + */ + + /** + * Constructs a new MigrationStateEvent. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a MigrationStateEvent. + * @implements IMigrationStateEvent + * @constructor + * @param {google.datastore.admin.v1.IMigrationStateEvent=} [properties] Properties to set + */ + function MigrationStateEvent(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MigrationStateEvent state. + * @member {google.datastore.admin.v1.MigrationState} state + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @instance + */ + MigrationStateEvent.prototype.state = 0; + + /** + * Creates a new MigrationStateEvent instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {google.datastore.admin.v1.IMigrationStateEvent=} [properties] Properties to set + * @returns {google.datastore.admin.v1.MigrationStateEvent} MigrationStateEvent instance + */ + MigrationStateEvent.create = function create(properties) { + return new MigrationStateEvent(properties); + }; + + /** + * Encodes the specified MigrationStateEvent message. Does not implicitly {@link google.datastore.admin.v1.MigrationStateEvent.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {google.datastore.admin.v1.IMigrationStateEvent} message MigrationStateEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MigrationStateEvent.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); + return writer; + }; + + /** + * Encodes the specified MigrationStateEvent message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationStateEvent.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {google.datastore.admin.v1.IMigrationStateEvent} message MigrationStateEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MigrationStateEvent.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MigrationStateEvent message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.MigrationStateEvent} MigrationStateEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MigrationStateEvent.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.MigrationStateEvent(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.state = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MigrationStateEvent message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.MigrationStateEvent} MigrationStateEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MigrationStateEvent.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MigrationStateEvent message. + * @function verify + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MigrationStateEvent.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + return null; + }; + + /** + * Creates a MigrationStateEvent message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.MigrationStateEvent} MigrationStateEvent + */ + MigrationStateEvent.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.MigrationStateEvent) + return object; + var message = new $root.google.datastore.admin.v1.MigrationStateEvent(); + switch (object.state) { + default: + if (typeof object.state === "number") { + message.state = object.state; + break; + } + break; + case "MIGRATION_STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "RUNNING": + case 1: + message.state = 1; + break; + case "PAUSED": + case 2: + message.state = 2; + break; + case "COMPLETE": + case 3: + message.state = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a MigrationStateEvent message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {google.datastore.admin.v1.MigrationStateEvent} message MigrationStateEvent + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MigrationStateEvent.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.state = options.enums === String ? "MIGRATION_STATE_UNSPECIFIED" : 0; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.datastore.admin.v1.MigrationState[message.state] === undefined ? message.state : $root.google.datastore.admin.v1.MigrationState[message.state] : message.state; + return object; + }; + + /** + * Converts this MigrationStateEvent to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @instance + * @returns {Object.} JSON object + */ + MigrationStateEvent.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MigrationStateEvent + * @function getTypeUrl + * @memberof google.datastore.admin.v1.MigrationStateEvent + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MigrationStateEvent.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.MigrationStateEvent"; + }; + + return MigrationStateEvent; + })(); + + v1.MigrationProgressEvent = (function() { + + /** + * Properties of a MigrationProgressEvent. + * @memberof google.datastore.admin.v1 + * @interface IMigrationProgressEvent + * @property {google.datastore.admin.v1.MigrationStep|null} [step] MigrationProgressEvent step + * @property {google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails|null} [prepareStepDetails] MigrationProgressEvent prepareStepDetails + * @property {google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails|null} [redirectWritesStepDetails] MigrationProgressEvent redirectWritesStepDetails + */ + + /** + * Constructs a new MigrationProgressEvent. + * @memberof google.datastore.admin.v1 + * @classdesc Represents a MigrationProgressEvent. + * @implements IMigrationProgressEvent + * @constructor + * @param {google.datastore.admin.v1.IMigrationProgressEvent=} [properties] Properties to set + */ + function MigrationProgressEvent(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MigrationProgressEvent step. + * @member {google.datastore.admin.v1.MigrationStep} step + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @instance + */ + MigrationProgressEvent.prototype.step = 0; + + /** + * MigrationProgressEvent prepareStepDetails. + * @member {google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails|null|undefined} prepareStepDetails + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @instance + */ + MigrationProgressEvent.prototype.prepareStepDetails = null; + + /** + * MigrationProgressEvent redirectWritesStepDetails. + * @member {google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails|null|undefined} redirectWritesStepDetails + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @instance + */ + MigrationProgressEvent.prototype.redirectWritesStepDetails = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * MigrationProgressEvent stepDetails. + * @member {"prepareStepDetails"|"redirectWritesStepDetails"|undefined} stepDetails + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @instance + */ + Object.defineProperty(MigrationProgressEvent.prototype, "stepDetails", { + get: $util.oneOfGetter($oneOfFields = ["prepareStepDetails", "redirectWritesStepDetails"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new MigrationProgressEvent instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {google.datastore.admin.v1.IMigrationProgressEvent=} [properties] Properties to set + * @returns {google.datastore.admin.v1.MigrationProgressEvent} MigrationProgressEvent instance + */ + MigrationProgressEvent.create = function create(properties) { + return new MigrationProgressEvent(properties); + }; + + /** + * Encodes the specified MigrationProgressEvent message. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {google.datastore.admin.v1.IMigrationProgressEvent} message MigrationProgressEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MigrationProgressEvent.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.step != null && Object.hasOwnProperty.call(message, "step")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.step); + if (message.prepareStepDetails != null && Object.hasOwnProperty.call(message, "prepareStepDetails")) + $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.encode(message.prepareStepDetails, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.redirectWritesStepDetails != null && Object.hasOwnProperty.call(message, "redirectWritesStepDetails")) + $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.encode(message.redirectWritesStepDetails, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MigrationProgressEvent message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {google.datastore.admin.v1.IMigrationProgressEvent} message MigrationProgressEvent message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MigrationProgressEvent.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MigrationProgressEvent message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.MigrationProgressEvent} MigrationProgressEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MigrationProgressEvent.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.MigrationProgressEvent(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.step = reader.int32(); + break; + } + case 2: { + message.prepareStepDetails = $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.decode(reader, reader.uint32()); + break; + } + case 3: { + message.redirectWritesStepDetails = $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MigrationProgressEvent message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.MigrationProgressEvent} MigrationProgressEvent + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MigrationProgressEvent.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MigrationProgressEvent message. + * @function verify + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MigrationProgressEvent.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.step != null && message.hasOwnProperty("step")) + switch (message.step) { + default: + return "step: enum value expected"; + case 0: + case 6: + case 1: + case 7: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.prepareStepDetails != null && message.hasOwnProperty("prepareStepDetails")) { + properties.stepDetails = 1; + { + var error = $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.verify(message.prepareStepDetails); + if (error) + return "prepareStepDetails." + error; + } + } + if (message.redirectWritesStepDetails != null && message.hasOwnProperty("redirectWritesStepDetails")) { + if (properties.stepDetails === 1) + return "stepDetails: multiple values"; + properties.stepDetails = 1; + { + var error = $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.verify(message.redirectWritesStepDetails); + if (error) + return "redirectWritesStepDetails." + error; + } + } + return null; + }; + + /** + * Creates a MigrationProgressEvent message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.MigrationProgressEvent} MigrationProgressEvent + */ + MigrationProgressEvent.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.MigrationProgressEvent) + return object; + var message = new $root.google.datastore.admin.v1.MigrationProgressEvent(); + switch (object.step) { + default: + if (typeof object.step === "number") { + message.step = object.step; + break; + } + break; + case "MIGRATION_STEP_UNSPECIFIED": + case 0: + message.step = 0; + break; + case "PREPARE": + case 6: + message.step = 6; + break; + case "START": + case 1: + message.step = 1; + break; + case "APPLY_WRITES_SYNCHRONOUSLY": + case 7: + message.step = 7; + break; + case "COPY_AND_VERIFY": + case 2: + message.step = 2; + break; + case "REDIRECT_EVENTUALLY_CONSISTENT_READS": + case 3: + message.step = 3; + break; + case "REDIRECT_STRONGLY_CONSISTENT_READS": + case 4: + message.step = 4; + break; + case "REDIRECT_WRITES": + case 5: + message.step = 5; + break; + } + if (object.prepareStepDetails != null) { + if (typeof object.prepareStepDetails !== "object") + throw TypeError(".google.datastore.admin.v1.MigrationProgressEvent.prepareStepDetails: object expected"); + message.prepareStepDetails = $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.fromObject(object.prepareStepDetails); + } + if (object.redirectWritesStepDetails != null) { + if (typeof object.redirectWritesStepDetails !== "object") + throw TypeError(".google.datastore.admin.v1.MigrationProgressEvent.redirectWritesStepDetails: object expected"); + message.redirectWritesStepDetails = $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.fromObject(object.redirectWritesStepDetails); + } + return message; + }; + + /** + * Creates a plain object from a MigrationProgressEvent message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent} message MigrationProgressEvent + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MigrationProgressEvent.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.step = options.enums === String ? "MIGRATION_STEP_UNSPECIFIED" : 0; + if (message.step != null && message.hasOwnProperty("step")) + object.step = options.enums === String ? $root.google.datastore.admin.v1.MigrationStep[message.step] === undefined ? message.step : $root.google.datastore.admin.v1.MigrationStep[message.step] : message.step; + if (message.prepareStepDetails != null && message.hasOwnProperty("prepareStepDetails")) { + object.prepareStepDetails = $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.toObject(message.prepareStepDetails, options); + if (options.oneofs) + object.stepDetails = "prepareStepDetails"; + } + if (message.redirectWritesStepDetails != null && message.hasOwnProperty("redirectWritesStepDetails")) { + object.redirectWritesStepDetails = $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.toObject(message.redirectWritesStepDetails, options); + if (options.oneofs) + object.stepDetails = "redirectWritesStepDetails"; + } + return object; + }; + + /** + * Converts this MigrationProgressEvent to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @instance + * @returns {Object.} JSON object + */ + MigrationProgressEvent.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MigrationProgressEvent + * @function getTypeUrl + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MigrationProgressEvent.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.MigrationProgressEvent"; + }; + + /** + * ConcurrencyMode enum. + * @name google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + * @enum {number} + * @property {number} CONCURRENCY_MODE_UNSPECIFIED=0 CONCURRENCY_MODE_UNSPECIFIED value + * @property {number} PESSIMISTIC=1 PESSIMISTIC value + * @property {number} OPTIMISTIC=2 OPTIMISTIC value + * @property {number} OPTIMISTIC_WITH_ENTITY_GROUPS=3 OPTIMISTIC_WITH_ENTITY_GROUPS value + */ + MigrationProgressEvent.ConcurrencyMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CONCURRENCY_MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PESSIMISTIC"] = 1; + values[valuesById[2] = "OPTIMISTIC"] = 2; + values[valuesById[3] = "OPTIMISTIC_WITH_ENTITY_GROUPS"] = 3; + return values; + })(); + + MigrationProgressEvent.PrepareStepDetails = (function() { + + /** + * Properties of a PrepareStepDetails. + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @interface IPrepareStepDetails + * @property {google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|null} [concurrencyMode] PrepareStepDetails concurrencyMode + */ + + /** + * Constructs a new PrepareStepDetails. + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @classdesc Represents a PrepareStepDetails. + * @implements IPrepareStepDetails + * @constructor + * @param {google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails=} [properties] Properties to set + */ + function PrepareStepDetails(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PrepareStepDetails concurrencyMode. + * @member {google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode} concurrencyMode + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @instance + */ + PrepareStepDetails.prototype.concurrencyMode = 0; + + /** + * Creates a new PrepareStepDetails instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails=} [properties] Properties to set + * @returns {google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails} PrepareStepDetails instance + */ + PrepareStepDetails.create = function create(properties) { + return new PrepareStepDetails(properties); + }; + + /** + * Encodes the specified PrepareStepDetails message. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails} message PrepareStepDetails message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PrepareStepDetails.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.concurrencyMode != null && Object.hasOwnProperty.call(message, "concurrencyMode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.concurrencyMode); + return writer; + }; + + /** + * Encodes the specified PrepareStepDetails message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.IPrepareStepDetails} message PrepareStepDetails message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PrepareStepDetails.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PrepareStepDetails message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails} PrepareStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PrepareStepDetails.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.concurrencyMode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PrepareStepDetails message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails} PrepareStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PrepareStepDetails.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PrepareStepDetails message. + * @function verify + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PrepareStepDetails.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.concurrencyMode != null && message.hasOwnProperty("concurrencyMode")) + switch (message.concurrencyMode) { + default: + return "concurrencyMode: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + return null; + }; + + /** + * Creates a PrepareStepDetails message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails} PrepareStepDetails + */ + PrepareStepDetails.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + return object; + var message = new $root.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails(); + switch (object.concurrencyMode) { + default: + if (typeof object.concurrencyMode === "number") { + message.concurrencyMode = object.concurrencyMode; + break; + } + break; + case "CONCURRENCY_MODE_UNSPECIFIED": + case 0: + message.concurrencyMode = 0; + break; + case "PESSIMISTIC": + case 1: + message.concurrencyMode = 1; + break; + case "OPTIMISTIC": + case 2: + message.concurrencyMode = 2; + break; + case "OPTIMISTIC_WITH_ENTITY_GROUPS": + case 3: + message.concurrencyMode = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a PrepareStepDetails message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails} message PrepareStepDetails + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PrepareStepDetails.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.concurrencyMode = options.enums === String ? "CONCURRENCY_MODE_UNSPECIFIED" : 0; + if (message.concurrencyMode != null && message.hasOwnProperty("concurrencyMode")) + object.concurrencyMode = options.enums === String ? $root.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode[message.concurrencyMode] === undefined ? message.concurrencyMode : $root.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode[message.concurrencyMode] : message.concurrencyMode; + return object; + }; + + /** + * Converts this PrepareStepDetails to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @instance + * @returns {Object.} JSON object + */ + PrepareStepDetails.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PrepareStepDetails + * @function getTypeUrl + * @memberof google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PrepareStepDetails.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails"; + }; + + return PrepareStepDetails; + })(); + + MigrationProgressEvent.RedirectWritesStepDetails = (function() { + + /** + * Properties of a RedirectWritesStepDetails. + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @interface IRedirectWritesStepDetails + * @property {google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode|null} [concurrencyMode] RedirectWritesStepDetails concurrencyMode + */ + + /** + * Constructs a new RedirectWritesStepDetails. + * @memberof google.datastore.admin.v1.MigrationProgressEvent + * @classdesc Represents a RedirectWritesStepDetails. + * @implements IRedirectWritesStepDetails + * @constructor + * @param {google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails=} [properties] Properties to set + */ + function RedirectWritesStepDetails(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RedirectWritesStepDetails concurrencyMode. + * @member {google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode} concurrencyMode + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @instance + */ + RedirectWritesStepDetails.prototype.concurrencyMode = 0; + + /** + * Creates a new RedirectWritesStepDetails instance using the specified properties. + * @function create + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails=} [properties] Properties to set + * @returns {google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails} RedirectWritesStepDetails instance + */ + RedirectWritesStepDetails.create = function create(properties) { + return new RedirectWritesStepDetails(properties); + }; + + /** + * Encodes the specified RedirectWritesStepDetails message. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.verify|verify} messages. + * @function encode + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails} message RedirectWritesStepDetails message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectWritesStepDetails.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.concurrencyMode != null && Object.hasOwnProperty.call(message, "concurrencyMode")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.concurrencyMode); + return writer; + }; + + /** + * Encodes the specified RedirectWritesStepDetails message, length delimited. Does not implicitly {@link google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.IRedirectWritesStepDetails} message RedirectWritesStepDetails message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RedirectWritesStepDetails.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RedirectWritesStepDetails message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails} RedirectWritesStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectWritesStepDetails.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.concurrencyMode = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RedirectWritesStepDetails message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails} RedirectWritesStepDetails + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RedirectWritesStepDetails.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RedirectWritesStepDetails message. + * @function verify + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RedirectWritesStepDetails.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.concurrencyMode != null && message.hasOwnProperty("concurrencyMode")) + switch (message.concurrencyMode) { + default: + return "concurrencyMode: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + return null; + }; + + /** + * Creates a RedirectWritesStepDetails message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails} RedirectWritesStepDetails + */ + RedirectWritesStepDetails.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + return object; + var message = new $root.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails(); + switch (object.concurrencyMode) { + default: + if (typeof object.concurrencyMode === "number") { + message.concurrencyMode = object.concurrencyMode; + break; + } + break; + case "CONCURRENCY_MODE_UNSPECIFIED": + case 0: + message.concurrencyMode = 0; + break; + case "PESSIMISTIC": + case 1: + message.concurrencyMode = 1; + break; + case "OPTIMISTIC": + case 2: + message.concurrencyMode = 2; + break; + case "OPTIMISTIC_WITH_ENTITY_GROUPS": + case 3: + message.concurrencyMode = 3; + break; + } + return message; + }; + + /** + * Creates a plain object from a RedirectWritesStepDetails message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails} message RedirectWritesStepDetails + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RedirectWritesStepDetails.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.concurrencyMode = options.enums === String ? "CONCURRENCY_MODE_UNSPECIFIED" : 0; + if (message.concurrencyMode != null && message.hasOwnProperty("concurrencyMode")) + object.concurrencyMode = options.enums === String ? $root.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode[message.concurrencyMode] === undefined ? message.concurrencyMode : $root.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode[message.concurrencyMode] : message.concurrencyMode; + return object; + }; + + /** + * Converts this RedirectWritesStepDetails to JSON. + * @function toJSON + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @instance + * @returns {Object.} JSON object + */ + RedirectWritesStepDetails.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RedirectWritesStepDetails + * @function getTypeUrl + * @memberof google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RedirectWritesStepDetails.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails"; + }; + + return RedirectWritesStepDetails; + })(); + + return MigrationProgressEvent; + })(); + + /** + * MigrationState enum. + * @name google.datastore.admin.v1.MigrationState + * @enum {number} + * @property {number} MIGRATION_STATE_UNSPECIFIED=0 MIGRATION_STATE_UNSPECIFIED value + * @property {number} RUNNING=1 RUNNING value + * @property {number} PAUSED=2 PAUSED value + * @property {number} COMPLETE=3 COMPLETE value + */ + v1.MigrationState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MIGRATION_STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "RUNNING"] = 1; + values[valuesById[2] = "PAUSED"] = 2; + values[valuesById[3] = "COMPLETE"] = 3; + return values; + })(); + + /** + * MigrationStep enum. + * @name google.datastore.admin.v1.MigrationStep + * @enum {number} + * @property {number} MIGRATION_STEP_UNSPECIFIED=0 MIGRATION_STEP_UNSPECIFIED value + * @property {number} PREPARE=6 PREPARE value + * @property {number} START=1 START value + * @property {number} APPLY_WRITES_SYNCHRONOUSLY=7 APPLY_WRITES_SYNCHRONOUSLY value + * @property {number} COPY_AND_VERIFY=2 COPY_AND_VERIFY value + * @property {number} REDIRECT_EVENTUALLY_CONSISTENT_READS=3 REDIRECT_EVENTUALLY_CONSISTENT_READS value + * @property {number} REDIRECT_STRONGLY_CONSISTENT_READS=4 REDIRECT_STRONGLY_CONSISTENT_READS value + * @property {number} REDIRECT_WRITES=5 REDIRECT_WRITES value + */ + v1.MigrationStep = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MIGRATION_STEP_UNSPECIFIED"] = 0; + values[valuesById[6] = "PREPARE"] = 6; + values[valuesById[1] = "START"] = 1; + values[valuesById[7] = "APPLY_WRITES_SYNCHRONOUSLY"] = 7; + values[valuesById[2] = "COPY_AND_VERIFY"] = 2; + values[valuesById[3] = "REDIRECT_EVENTUALLY_CONSISTENT_READS"] = 3; + values[valuesById[4] = "REDIRECT_STRONGLY_CONSISTENT_READS"] = 4; + values[valuesById[5] = "REDIRECT_WRITES"] = 5; + return values; + })(); + + return v1; + })(); + + return admin; + })(); + + datastore.v1 = (function() { + + /** + * Namespace v1. + * @memberof google.datastore + * @namespace + */ + var v1 = {}; + + v1.AggregationResult = (function() { + + /** + * Properties of an AggregationResult. + * @memberof google.datastore.v1 + * @interface IAggregationResult + * @property {Object.|null} [aggregateProperties] AggregationResult aggregateProperties + */ + + /** + * Constructs a new AggregationResult. + * @memberof google.datastore.v1 + * @classdesc Represents an AggregationResult. + * @implements IAggregationResult + * @constructor + * @param {google.datastore.v1.IAggregationResult=} [properties] Properties to set + */ + function AggregationResult(properties) { + this.aggregateProperties = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * AggregationResult aggregateProperties. + * @member {Object.} aggregateProperties + * @memberof google.datastore.v1.AggregationResult + * @instance + */ + AggregationResult.prototype.aggregateProperties = $util.emptyObject; + + /** + * Creates a new AggregationResult instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {google.datastore.v1.IAggregationResult=} [properties] Properties to set + * @returns {google.datastore.v1.AggregationResult} AggregationResult instance + */ + AggregationResult.create = function create(properties) { + return new AggregationResult(properties); + }; + + /** + * Encodes the specified AggregationResult message. Does not implicitly {@link google.datastore.v1.AggregationResult.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {google.datastore.v1.IAggregationResult} message AggregationResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AggregationResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.aggregateProperties != null && Object.hasOwnProperty.call(message, "aggregateProperties")) + for (var keys = Object.keys(message.aggregateProperties), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.datastore.v1.Value.encode(message.aggregateProperties[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified AggregationResult message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {google.datastore.v1.IAggregationResult} message AggregationResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AggregationResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AggregationResult message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AggregationResult} AggregationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AggregationResult.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AggregationResult(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (message.aggregateProperties === $util.emptyObject) + message.aggregateProperties = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.aggregateProperties[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AggregationResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AggregationResult} AggregationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AggregationResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AggregationResult message. + * @function verify + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AggregationResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.aggregateProperties != null && message.hasOwnProperty("aggregateProperties")) { + if (!$util.isObject(message.aggregateProperties)) + return "aggregateProperties: object expected"; + var key = Object.keys(message.aggregateProperties); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.datastore.v1.Value.verify(message.aggregateProperties[key[i]]); + if (error) + return "aggregateProperties." + error; + } + } + return null; + }; + + /** + * Creates an AggregationResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AggregationResult} AggregationResult + */ + AggregationResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AggregationResult) + return object; + var message = new $root.google.datastore.v1.AggregationResult(); + if (object.aggregateProperties) { + if (typeof object.aggregateProperties !== "object") + throw TypeError(".google.datastore.v1.AggregationResult.aggregateProperties: object expected"); + message.aggregateProperties = {}; + for (var keys = Object.keys(object.aggregateProperties), i = 0; i < keys.length; ++i) { + if (typeof object.aggregateProperties[keys[i]] !== "object") + throw TypeError(".google.datastore.v1.AggregationResult.aggregateProperties: object expected"); + message.aggregateProperties[keys[i]] = $root.google.datastore.v1.Value.fromObject(object.aggregateProperties[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from an AggregationResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {google.datastore.v1.AggregationResult} message AggregationResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AggregationResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.aggregateProperties = {}; + var keys2; + if (message.aggregateProperties && (keys2 = Object.keys(message.aggregateProperties)).length) { + object.aggregateProperties = {}; + for (var j = 0; j < keys2.length; ++j) + object.aggregateProperties[keys2[j]] = $root.google.datastore.v1.Value.toObject(message.aggregateProperties[keys2[j]], options); + } + return object; + }; + + /** + * Converts this AggregationResult to JSON. + * @function toJSON + * @memberof google.datastore.v1.AggregationResult + * @instance + * @returns {Object.} JSON object + */ + AggregationResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AggregationResult + * @function getTypeUrl + * @memberof google.datastore.v1.AggregationResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AggregationResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AggregationResult"; + }; + + return AggregationResult; + })(); + + v1.AggregationResultBatch = (function() { + + /** + * Properties of an AggregationResultBatch. + * @memberof google.datastore.v1 + * @interface IAggregationResultBatch + * @property {Array.|null} [aggregationResults] AggregationResultBatch aggregationResults + * @property {google.datastore.v1.QueryResultBatch.MoreResultsType|null} [moreResults] AggregationResultBatch moreResults + * @property {google.protobuf.ITimestamp|null} [readTime] AggregationResultBatch readTime + */ + + /** + * Constructs a new AggregationResultBatch. + * @memberof google.datastore.v1 + * @classdesc Represents an AggregationResultBatch. + * @implements IAggregationResultBatch + * @constructor + * @param {google.datastore.v1.IAggregationResultBatch=} [properties] Properties to set + */ + function AggregationResultBatch(properties) { + this.aggregationResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * AggregationResultBatch aggregationResults. + * @member {Array.} aggregationResults + * @memberof google.datastore.v1.AggregationResultBatch + * @instance + */ + AggregationResultBatch.prototype.aggregationResults = $util.emptyArray; + + /** + * AggregationResultBatch moreResults. + * @member {google.datastore.v1.QueryResultBatch.MoreResultsType} moreResults + * @memberof google.datastore.v1.AggregationResultBatch + * @instance + */ + AggregationResultBatch.prototype.moreResults = 0; + + /** + * AggregationResultBatch readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.datastore.v1.AggregationResultBatch + * @instance + */ + AggregationResultBatch.prototype.readTime = null; + + /** + * Creates a new AggregationResultBatch instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {google.datastore.v1.IAggregationResultBatch=} [properties] Properties to set + * @returns {google.datastore.v1.AggregationResultBatch} AggregationResultBatch instance + */ + AggregationResultBatch.create = function create(properties) { + return new AggregationResultBatch(properties); + }; + + /** + * Encodes the specified AggregationResultBatch message. Does not implicitly {@link google.datastore.v1.AggregationResultBatch.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {google.datastore.v1.IAggregationResultBatch} message AggregationResultBatch message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AggregationResultBatch.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.aggregationResults != null && message.aggregationResults.length) + for (var i = 0; i < message.aggregationResults.length; ++i) + $root.google.datastore.v1.AggregationResult.encode(message.aggregationResults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.moreResults != null && Object.hasOwnProperty.call(message, "moreResults")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.moreResults); + if (message.readTime != null && Object.hasOwnProperty.call(message, "readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AggregationResultBatch message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationResultBatch.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {google.datastore.v1.IAggregationResultBatch} message AggregationResultBatch message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AggregationResultBatch.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AggregationResultBatch message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AggregationResultBatch} AggregationResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AggregationResultBatch.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AggregationResultBatch(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.aggregationResults && message.aggregationResults.length)) + message.aggregationResults = []; + message.aggregationResults.push($root.google.datastore.v1.AggregationResult.decode(reader, reader.uint32())); + break; + } + case 2: { + message.moreResults = reader.int32(); + break; + } + case 3: { + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AggregationResultBatch message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AggregationResultBatch} AggregationResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AggregationResultBatch.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AggregationResultBatch message. + * @function verify + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AggregationResultBatch.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.aggregationResults != null && message.hasOwnProperty("aggregationResults")) { + if (!Array.isArray(message.aggregationResults)) + return "aggregationResults: array expected"; + for (var i = 0; i < message.aggregationResults.length; ++i) { + var error = $root.google.datastore.v1.AggregationResult.verify(message.aggregationResults[i]); + if (error) + return "aggregationResults." + error; + } + } + if (message.moreResults != null && message.hasOwnProperty("moreResults")) + switch (message.moreResults) { + default: + return "moreResults: enum value expected"; + case 0: + case 1: + case 2: + case 4: + case 3: + break; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return null; + }; + + /** + * Creates an AggregationResultBatch message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AggregationResultBatch} AggregationResultBatch + */ + AggregationResultBatch.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AggregationResultBatch) + return object; + var message = new $root.google.datastore.v1.AggregationResultBatch(); + if (object.aggregationResults) { + if (!Array.isArray(object.aggregationResults)) + throw TypeError(".google.datastore.v1.AggregationResultBatch.aggregationResults: array expected"); + message.aggregationResults = []; + for (var i = 0; i < object.aggregationResults.length; ++i) { + if (typeof object.aggregationResults[i] !== "object") + throw TypeError(".google.datastore.v1.AggregationResultBatch.aggregationResults: object expected"); + message.aggregationResults[i] = $root.google.datastore.v1.AggregationResult.fromObject(object.aggregationResults[i]); + } + } + switch (object.moreResults) { + default: + if (typeof object.moreResults === "number") { + message.moreResults = object.moreResults; + break; + } + break; + case "MORE_RESULTS_TYPE_UNSPECIFIED": + case 0: + message.moreResults = 0; + break; + case "NOT_FINISHED": + case 1: + message.moreResults = 1; + break; + case "MORE_RESULTS_AFTER_LIMIT": + case 2: + message.moreResults = 2; + break; + case "MORE_RESULTS_AFTER_CURSOR": + case 4: + message.moreResults = 4; + break; + case "NO_MORE_RESULTS": + case 3: + message.moreResults = 3; + break; + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.datastore.v1.AggregationResultBatch.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from an AggregationResultBatch message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {google.datastore.v1.AggregationResultBatch} message AggregationResultBatch + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AggregationResultBatch.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.aggregationResults = []; + if (options.defaults) { + object.moreResults = options.enums === String ? "MORE_RESULTS_TYPE_UNSPECIFIED" : 0; + object.readTime = null; + } + if (message.aggregationResults && message.aggregationResults.length) { + object.aggregationResults = []; + for (var j = 0; j < message.aggregationResults.length; ++j) + object.aggregationResults[j] = $root.google.datastore.v1.AggregationResult.toObject(message.aggregationResults[j], options); + } + if (message.moreResults != null && message.hasOwnProperty("moreResults")) + object.moreResults = options.enums === String ? $root.google.datastore.v1.QueryResultBatch.MoreResultsType[message.moreResults] === undefined ? message.moreResults : $root.google.datastore.v1.QueryResultBatch.MoreResultsType[message.moreResults] : message.moreResults; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this AggregationResultBatch to JSON. + * @function toJSON + * @memberof google.datastore.v1.AggregationResultBatch + * @instance + * @returns {Object.} JSON object + */ + AggregationResultBatch.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AggregationResultBatch + * @function getTypeUrl + * @memberof google.datastore.v1.AggregationResultBatch + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AggregationResultBatch.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AggregationResultBatch"; + }; + + return AggregationResultBatch; + })(); + + v1.PartitionId = (function() { + + /** + * Properties of a PartitionId. + * @memberof google.datastore.v1 + * @interface IPartitionId + * @property {string|null} [projectId] PartitionId projectId + * @property {string|null} [databaseId] PartitionId databaseId + * @property {string|null} [namespaceId] PartitionId namespaceId + */ + + /** + * Constructs a new PartitionId. + * @memberof google.datastore.v1 + * @classdesc Represents a PartitionId. + * @implements IPartitionId + * @constructor + * @param {google.datastore.v1.IPartitionId=} [properties] Properties to set + */ + function PartitionId(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PartitionId projectId. + * @member {string} projectId + * @memberof google.datastore.v1.PartitionId + * @instance + */ + PartitionId.prototype.projectId = ""; + + /** + * PartitionId databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.PartitionId + * @instance + */ + PartitionId.prototype.databaseId = ""; + + /** + * PartitionId namespaceId. + * @member {string} namespaceId + * @memberof google.datastore.v1.PartitionId + * @instance + */ + PartitionId.prototype.namespaceId = ""; + + /** + * Creates a new PartitionId instance using the specified properties. + * @function create + * @memberof google.datastore.v1.PartitionId + * @static + * @param {google.datastore.v1.IPartitionId=} [properties] Properties to set + * @returns {google.datastore.v1.PartitionId} PartitionId instance + */ + PartitionId.create = function create(properties) { + return new PartitionId(properties); + }; + + /** + * Encodes the specified PartitionId message. Does not implicitly {@link google.datastore.v1.PartitionId.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.PartitionId + * @static + * @param {google.datastore.v1.IPartitionId} message PartitionId message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PartitionId.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.databaseId); + if (message.namespaceId != null && Object.hasOwnProperty.call(message, "namespaceId")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.namespaceId); + return writer; + }; + + /** + * Encodes the specified PartitionId message, length delimited. Does not implicitly {@link google.datastore.v1.PartitionId.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.PartitionId + * @static + * @param {google.datastore.v1.IPartitionId} message PartitionId message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PartitionId.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PartitionId message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.PartitionId + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.PartitionId} PartitionId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PartitionId.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.PartitionId(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.projectId = reader.string(); + break; + } + case 3: { + message.databaseId = reader.string(); + break; + } + case 4: { + message.namespaceId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PartitionId message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.PartitionId + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.PartitionId} PartitionId + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PartitionId.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PartitionId message. + * @function verify + * @memberof google.datastore.v1.PartitionId + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PartitionId.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.namespaceId != null && message.hasOwnProperty("namespaceId")) + if (!$util.isString(message.namespaceId)) + return "namespaceId: string expected"; + return null; + }; + + /** + * Creates a PartitionId message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.PartitionId + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.PartitionId} PartitionId + */ + PartitionId.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.PartitionId) + return object; + var message = new $root.google.datastore.v1.PartitionId(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.namespaceId != null) + message.namespaceId = String(object.namespaceId); + return message; + }; + + /** + * Creates a plain object from a PartitionId message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.PartitionId + * @static + * @param {google.datastore.v1.PartitionId} message PartitionId + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PartitionId.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.projectId = ""; + object.databaseId = ""; + object.namespaceId = ""; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + if (message.namespaceId != null && message.hasOwnProperty("namespaceId")) + object.namespaceId = message.namespaceId; + return object; + }; + + /** + * Converts this PartitionId to JSON. + * @function toJSON + * @memberof google.datastore.v1.PartitionId + * @instance + * @returns {Object.} JSON object + */ + PartitionId.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PartitionId + * @function getTypeUrl + * @memberof google.datastore.v1.PartitionId + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PartitionId.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.PartitionId"; + }; + + return PartitionId; + })(); + + v1.Key = (function() { + + /** + * Properties of a Key. + * @memberof google.datastore.v1 + * @interface IKey + * @property {google.datastore.v1.IPartitionId|null} [partitionId] Key partitionId + * @property {Array.|null} [path] Key path + */ + + /** + * Constructs a new Key. + * @memberof google.datastore.v1 + * @classdesc Represents a Key. + * @implements IKey + * @constructor + * @param {google.datastore.v1.IKey=} [properties] Properties to set + */ + function Key(properties) { + this.path = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Key partitionId. + * @member {google.datastore.v1.IPartitionId|null|undefined} partitionId + * @memberof google.datastore.v1.Key + * @instance + */ + Key.prototype.partitionId = null; + + /** + * Key path. + * @member {Array.} path + * @memberof google.datastore.v1.Key + * @instance + */ + Key.prototype.path = $util.emptyArray; + + /** + * Creates a new Key instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Key + * @static + * @param {google.datastore.v1.IKey=} [properties] Properties to set + * @returns {google.datastore.v1.Key} Key instance + */ + Key.create = function create(properties) { + return new Key(properties); + }; + + /** + * Encodes the specified Key message. Does not implicitly {@link google.datastore.v1.Key.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Key + * @static + * @param {google.datastore.v1.IKey} message Key message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Key.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.partitionId != null && Object.hasOwnProperty.call(message, "partitionId")) + $root.google.datastore.v1.PartitionId.encode(message.partitionId, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.path != null && message.path.length) + for (var i = 0; i < message.path.length; ++i) + $root.google.datastore.v1.Key.PathElement.encode(message.path[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Key message, length delimited. Does not implicitly {@link google.datastore.v1.Key.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Key + * @static + * @param {google.datastore.v1.IKey} message Key message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Key.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Key message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Key + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Key} Key + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Key.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Key(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.partitionId = $root.google.datastore.v1.PartitionId.decode(reader, reader.uint32()); + break; + } + case 2: { + if (!(message.path && message.path.length)) + message.path = []; + message.path.push($root.google.datastore.v1.Key.PathElement.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Key message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Key + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Key} Key + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Key.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Key message. + * @function verify + * @memberof google.datastore.v1.Key + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Key.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.partitionId != null && message.hasOwnProperty("partitionId")) { + var error = $root.google.datastore.v1.PartitionId.verify(message.partitionId); + if (error) + return "partitionId." + error; + } + if (message.path != null && message.hasOwnProperty("path")) { + if (!Array.isArray(message.path)) + return "path: array expected"; + for (var i = 0; i < message.path.length; ++i) { + var error = $root.google.datastore.v1.Key.PathElement.verify(message.path[i]); + if (error) + return "path." + error; + } + } + return null; + }; + + /** + * Creates a Key message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Key + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Key} Key + */ + Key.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Key) + return object; + var message = new $root.google.datastore.v1.Key(); + if (object.partitionId != null) { + if (typeof object.partitionId !== "object") + throw TypeError(".google.datastore.v1.Key.partitionId: object expected"); + message.partitionId = $root.google.datastore.v1.PartitionId.fromObject(object.partitionId); + } + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.datastore.v1.Key.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) { + if (typeof object.path[i] !== "object") + throw TypeError(".google.datastore.v1.Key.path: object expected"); + message.path[i] = $root.google.datastore.v1.Key.PathElement.fromObject(object.path[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Key message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Key + * @static + * @param {google.datastore.v1.Key} message Key + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Key.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.path = []; + if (options.defaults) + object.partitionId = null; + if (message.partitionId != null && message.hasOwnProperty("partitionId")) + object.partitionId = $root.google.datastore.v1.PartitionId.toObject(message.partitionId, options); + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = $root.google.datastore.v1.Key.PathElement.toObject(message.path[j], options); + } + return object; + }; + + /** + * Converts this Key to JSON. + * @function toJSON + * @memberof google.datastore.v1.Key + * @instance + * @returns {Object.} JSON object + */ + Key.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Key + * @function getTypeUrl + * @memberof google.datastore.v1.Key + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Key.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Key"; + }; + + Key.PathElement = (function() { + + /** + * Properties of a PathElement. + * @memberof google.datastore.v1.Key + * @interface IPathElement + * @property {string|null} [kind] PathElement kind + * @property {number|Long|null} [id] PathElement id + * @property {string|null} [name] PathElement name + */ + + /** + * Constructs a new PathElement. + * @memberof google.datastore.v1.Key + * @classdesc Represents a PathElement. + * @implements IPathElement + * @constructor + * @param {google.datastore.v1.Key.IPathElement=} [properties] Properties to set + */ + function PathElement(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PathElement kind. + * @member {string} kind + * @memberof google.datastore.v1.Key.PathElement + * @instance + */ + PathElement.prototype.kind = ""; + + /** + * PathElement id. + * @member {number|Long|null|undefined} id + * @memberof google.datastore.v1.Key.PathElement + * @instance + */ + PathElement.prototype.id = null; + + /** + * PathElement name. + * @member {string|null|undefined} name + * @memberof google.datastore.v1.Key.PathElement + * @instance + */ + PathElement.prototype.name = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * PathElement idType. + * @member {"id"|"name"|undefined} idType + * @memberof google.datastore.v1.Key.PathElement + * @instance + */ + Object.defineProperty(PathElement.prototype, "idType", { + get: $util.oneOfGetter($oneOfFields = ["id", "name"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new PathElement instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {google.datastore.v1.Key.IPathElement=} [properties] Properties to set + * @returns {google.datastore.v1.Key.PathElement} PathElement instance + */ + PathElement.create = function create(properties) { + return new PathElement(properties); + }; + + /** + * Encodes the specified PathElement message. Does not implicitly {@link google.datastore.v1.Key.PathElement.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {google.datastore.v1.Key.IPathElement} message PathElement message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PathElement.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.kind != null && Object.hasOwnProperty.call(message, "kind")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.kind); + if (message.id != null && Object.hasOwnProperty.call(message, "id")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.id); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.name); + return writer; + }; + + /** + * Encodes the specified PathElement message, length delimited. Does not implicitly {@link google.datastore.v1.Key.PathElement.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {google.datastore.v1.Key.IPathElement} message PathElement message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PathElement.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PathElement message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Key.PathElement} PathElement + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PathElement.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Key.PathElement(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.kind = reader.string(); + break; + } + case 2: { + message.id = reader.int64(); + break; + } + case 3: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PathElement message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Key.PathElement} PathElement + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PathElement.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PathElement message. + * @function verify + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PathElement.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.kind != null && message.hasOwnProperty("kind")) + if (!$util.isString(message.kind)) + return "kind: string expected"; + if (message.id != null && message.hasOwnProperty("id")) { + properties.idType = 1; + if (!$util.isInteger(message.id) && !(message.id && $util.isInteger(message.id.low) && $util.isInteger(message.id.high))) + return "id: integer|Long expected"; + } + if (message.name != null && message.hasOwnProperty("name")) { + if (properties.idType === 1) + return "idType: multiple values"; + properties.idType = 1; + if (!$util.isString(message.name)) + return "name: string expected"; + } + return null; + }; + + /** + * Creates a PathElement message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Key.PathElement} PathElement + */ + PathElement.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Key.PathElement) + return object; + var message = new $root.google.datastore.v1.Key.PathElement(); + if (object.kind != null) + message.kind = String(object.kind); + if (object.id != null) + if ($util.Long) + (message.id = $util.Long.fromValue(object.id)).unsigned = false; + else if (typeof object.id === "string") + message.id = parseInt(object.id, 10); + else if (typeof object.id === "number") + message.id = object.id; + else if (typeof object.id === "object") + message.id = new $util.LongBits(object.id.low >>> 0, object.id.high >>> 0).toNumber(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a PathElement message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {google.datastore.v1.Key.PathElement} message PathElement + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PathElement.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.kind = ""; + if (message.kind != null && message.hasOwnProperty("kind")) + object.kind = message.kind; + if (message.id != null && message.hasOwnProperty("id")) { + if (typeof message.id === "number") + object.id = options.longs === String ? String(message.id) : message.id; + else + object.id = options.longs === String ? $util.Long.prototype.toString.call(message.id) : options.longs === Number ? new $util.LongBits(message.id.low >>> 0, message.id.high >>> 0).toNumber() : message.id; + if (options.oneofs) + object.idType = "id"; + } + if (message.name != null && message.hasOwnProperty("name")) { + object.name = message.name; + if (options.oneofs) + object.idType = "name"; + } + return object; + }; + + /** + * Converts this PathElement to JSON. + * @function toJSON + * @memberof google.datastore.v1.Key.PathElement + * @instance + * @returns {Object.} JSON object + */ + PathElement.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PathElement + * @function getTypeUrl + * @memberof google.datastore.v1.Key.PathElement + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PathElement.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Key.PathElement"; + }; + + return PathElement; + })(); + + return Key; + })(); + + v1.ArrayValue = (function() { + + /** + * Properties of an ArrayValue. + * @memberof google.datastore.v1 + * @interface IArrayValue + * @property {Array.|null} [values] ArrayValue values + */ + + /** + * Constructs a new ArrayValue. + * @memberof google.datastore.v1 + * @classdesc Represents an ArrayValue. + * @implements IArrayValue + * @constructor + * @param {google.datastore.v1.IArrayValue=} [properties] Properties to set + */ + function ArrayValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ArrayValue values. + * @member {Array.} values + * @memberof google.datastore.v1.ArrayValue + * @instance + */ + ArrayValue.prototype.values = $util.emptyArray; + + /** + * Creates a new ArrayValue instance using the specified properties. + * @function create + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {google.datastore.v1.IArrayValue=} [properties] Properties to set + * @returns {google.datastore.v1.ArrayValue} ArrayValue instance + */ + ArrayValue.create = function create(properties) { + return new ArrayValue(properties); + }; + + /** + * Encodes the specified ArrayValue message. Does not implicitly {@link google.datastore.v1.ArrayValue.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {google.datastore.v1.IArrayValue} message ArrayValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ArrayValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.datastore.v1.Value.encode(message.values[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ArrayValue message, length delimited. Does not implicitly {@link google.datastore.v1.ArrayValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {google.datastore.v1.IArrayValue} message ArrayValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ArrayValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ArrayValue message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.ArrayValue} ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ArrayValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.ArrayValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.datastore.v1.Value.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ArrayValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.ArrayValue} ArrayValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ArrayValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ArrayValue message. + * @function verify + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ArrayValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.values != null && message.hasOwnProperty("values")) { + if (!Array.isArray(message.values)) + return "values: array expected"; + for (var i = 0; i < message.values.length; ++i) { + var error = $root.google.datastore.v1.Value.verify(message.values[i]); + if (error) + return "values." + error; + } + } + return null; + }; + + /** + * Creates an ArrayValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.ArrayValue} ArrayValue + */ + ArrayValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.ArrayValue) + return object; + var message = new $root.google.datastore.v1.ArrayValue(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.datastore.v1.ArrayValue.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.datastore.v1.ArrayValue.values: object expected"); + message.values[i] = $root.google.datastore.v1.Value.fromObject(object.values[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an ArrayValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {google.datastore.v1.ArrayValue} message ArrayValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ArrayValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.datastore.v1.Value.toObject(message.values[j], options); + } + return object; + }; + + /** + * Converts this ArrayValue to JSON. + * @function toJSON + * @memberof google.datastore.v1.ArrayValue + * @instance + * @returns {Object.} JSON object + */ + ArrayValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ArrayValue + * @function getTypeUrl + * @memberof google.datastore.v1.ArrayValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ArrayValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.ArrayValue"; + }; + + return ArrayValue; + })(); + + v1.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.datastore.v1 + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {boolean|null} [booleanValue] Value booleanValue + * @property {number|Long|null} [integerValue] Value integerValue + * @property {number|null} [doubleValue] Value doubleValue + * @property {google.protobuf.ITimestamp|null} [timestampValue] Value timestampValue + * @property {google.datastore.v1.IKey|null} [keyValue] Value keyValue + * @property {string|null} [stringValue] Value stringValue + * @property {Uint8Array|null} [blobValue] Value blobValue + * @property {google.type.ILatLng|null} [geoPointValue] Value geoPointValue + * @property {google.datastore.v1.IEntity|null} [entityValue] Value entityValue + * @property {google.datastore.v1.IArrayValue|null} [arrayValue] Value arrayValue + * @property {number|null} [meaning] Value meaning + * @property {boolean|null} [excludeFromIndexes] Value excludeFromIndexes + */ + + /** + * Constructs a new Value. + * @memberof google.datastore.v1 + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.datastore.v1.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue|null|undefined} nullValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.nullValue = null; + + /** + * Value booleanValue. + * @member {boolean|null|undefined} booleanValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.booleanValue = null; + + /** + * Value integerValue. + * @member {number|Long|null|undefined} integerValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.integerValue = null; + + /** + * Value doubleValue. + * @member {number|null|undefined} doubleValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.doubleValue = null; + + /** + * Value timestampValue. + * @member {google.protobuf.ITimestamp|null|undefined} timestampValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.timestampValue = null; + + /** + * Value keyValue. + * @member {google.datastore.v1.IKey|null|undefined} keyValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.keyValue = null; + + /** + * Value stringValue. + * @member {string|null|undefined} stringValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.stringValue = null; + + /** + * Value blobValue. + * @member {Uint8Array|null|undefined} blobValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.blobValue = null; + + /** + * Value geoPointValue. + * @member {google.type.ILatLng|null|undefined} geoPointValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.geoPointValue = null; + + /** + * Value entityValue. + * @member {google.datastore.v1.IEntity|null|undefined} entityValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.entityValue = null; + + /** + * Value arrayValue. + * @member {google.datastore.v1.IArrayValue|null|undefined} arrayValue + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.arrayValue = null; + + /** + * Value meaning. + * @member {number} meaning + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.meaning = 0; + + /** + * Value excludeFromIndexes. + * @member {boolean} excludeFromIndexes + * @memberof google.datastore.v1.Value + * @instance + */ + Value.prototype.excludeFromIndexes = false; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value valueType. + * @member {"nullValue"|"booleanValue"|"integerValue"|"doubleValue"|"timestampValue"|"keyValue"|"stringValue"|"blobValue"|"geoPointValue"|"entityValue"|"arrayValue"|undefined} valueType + * @memberof google.datastore.v1.Value + * @instance + */ + Object.defineProperty(Value.prototype, "valueType", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "booleanValue", "integerValue", "doubleValue", "timestampValue", "keyValue", "stringValue", "blobValue", "geoPointValue", "entityValue", "arrayValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Value instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Value + * @static + * @param {google.datastore.v1.IValue=} [properties] Properties to set + * @returns {google.datastore.v1.Value} Value instance + */ + Value.create = function create(properties) { + return new Value(properties); + }; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.datastore.v1.Value.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Value + * @static + * @param {google.datastore.v1.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.booleanValue != null && Object.hasOwnProperty.call(message, "booleanValue")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.booleanValue); + if (message.integerValue != null && Object.hasOwnProperty.call(message, "integerValue")) + writer.uint32(/* id 2, wireType 0 =*/16).int64(message.integerValue); + if (message.doubleValue != null && Object.hasOwnProperty.call(message, "doubleValue")) + writer.uint32(/* id 3, wireType 1 =*/25).double(message.doubleValue); + if (message.keyValue != null && Object.hasOwnProperty.call(message, "keyValue")) + $root.google.datastore.v1.Key.encode(message.keyValue, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.entityValue != null && Object.hasOwnProperty.call(message, "entityValue")) + $root.google.datastore.v1.Entity.encode(message.entityValue, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.geoPointValue != null && Object.hasOwnProperty.call(message, "geoPointValue")) + $root.google.type.LatLng.encode(message.geoPointValue, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.arrayValue != null && Object.hasOwnProperty.call(message, "arrayValue")) + $root.google.datastore.v1.ArrayValue.encode(message.arrayValue, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.timestampValue != null && Object.hasOwnProperty.call(message, "timestampValue")) + $root.google.protobuf.Timestamp.encode(message.timestampValue, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.nullValue != null && Object.hasOwnProperty.call(message, "nullValue")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.nullValue); + if (message.meaning != null && Object.hasOwnProperty.call(message, "meaning")) + writer.uint32(/* id 14, wireType 0 =*/112).int32(message.meaning); + if (message.stringValue != null && Object.hasOwnProperty.call(message, "stringValue")) + writer.uint32(/* id 17, wireType 2 =*/138).string(message.stringValue); + if (message.blobValue != null && Object.hasOwnProperty.call(message, "blobValue")) + writer.uint32(/* id 18, wireType 2 =*/146).bytes(message.blobValue); + if (message.excludeFromIndexes != null && Object.hasOwnProperty.call(message, "excludeFromIndexes")) + writer.uint32(/* id 19, wireType 0 =*/152).bool(message.excludeFromIndexes); + return writer; + }; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.datastore.v1.Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Value + * @static + * @param {google.datastore.v1.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Value message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 11: { + message.nullValue = reader.int32(); + break; + } + case 1: { + message.booleanValue = reader.bool(); + break; + } + case 2: { + message.integerValue = reader.int64(); + break; + } + case 3: { + message.doubleValue = reader.double(); + break; + } + case 10: { + message.timestampValue = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.keyValue = $root.google.datastore.v1.Key.decode(reader, reader.uint32()); + break; + } + case 17: { + message.stringValue = reader.string(); + break; + } + case 18: { + message.blobValue = reader.bytes(); + break; + } + case 8: { + message.geoPointValue = $root.google.type.LatLng.decode(reader, reader.uint32()); + break; + } + case 6: { + message.entityValue = $root.google.datastore.v1.Entity.decode(reader, reader.uint32()); + break; + } + case 9: { + message.arrayValue = $root.google.datastore.v1.ArrayValue.decode(reader, reader.uint32()); + break; + } + case 14: { + message.meaning = reader.int32(); + break; + } + case 19: { + message.excludeFromIndexes = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Value message. + * @function verify + * @memberof google.datastore.v1.Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + properties.valueType = 1; + switch (message.nullValue) { + default: + return "nullValue: enum value expected"; + case 0: + break; + } + } + if (message.booleanValue != null && message.hasOwnProperty("booleanValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (typeof message.booleanValue !== "boolean") + return "booleanValue: boolean expected"; + } + if (message.integerValue != null && message.hasOwnProperty("integerValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (!$util.isInteger(message.integerValue) && !(message.integerValue && $util.isInteger(message.integerValue.low) && $util.isInteger(message.integerValue.high))) + return "integerValue: integer|Long expected"; + } + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (typeof message.doubleValue !== "number") + return "doubleValue: number expected"; + } + if (message.timestampValue != null && message.hasOwnProperty("timestampValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.timestampValue); + if (error) + return "timestampValue." + error; + } + } + if (message.keyValue != null && message.hasOwnProperty("keyValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.datastore.v1.Key.verify(message.keyValue); + if (error) + return "keyValue." + error; + } + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (!$util.isString(message.stringValue)) + return "stringValue: string expected"; + } + if (message.blobValue != null && message.hasOwnProperty("blobValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + if (!(message.blobValue && typeof message.blobValue.length === "number" || $util.isString(message.blobValue))) + return "blobValue: buffer expected"; + } + if (message.geoPointValue != null && message.hasOwnProperty("geoPointValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.type.LatLng.verify(message.geoPointValue); + if (error) + return "geoPointValue." + error; + } + } + if (message.entityValue != null && message.hasOwnProperty("entityValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.datastore.v1.Entity.verify(message.entityValue); + if (error) + return "entityValue." + error; + } + } + if (message.arrayValue != null && message.hasOwnProperty("arrayValue")) { + if (properties.valueType === 1) + return "valueType: multiple values"; + properties.valueType = 1; + { + var error = $root.google.datastore.v1.ArrayValue.verify(message.arrayValue); + if (error) + return "arrayValue." + error; + } + } + if (message.meaning != null && message.hasOwnProperty("meaning")) + if (!$util.isInteger(message.meaning)) + return "meaning: integer expected"; + if (message.excludeFromIndexes != null && message.hasOwnProperty("excludeFromIndexes")) + if (typeof message.excludeFromIndexes !== "boolean") + return "excludeFromIndexes: boolean expected"; + return null; + }; + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Value + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Value} Value + */ + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Value) + return object; + var message = new $root.google.datastore.v1.Value(); + switch (object.nullValue) { + default: + if (typeof object.nullValue === "number") { + message.nullValue = object.nullValue; + break; + } + break; + case "NULL_VALUE": + case 0: + message.nullValue = 0; + break; + } + if (object.booleanValue != null) + message.booleanValue = Boolean(object.booleanValue); + if (object.integerValue != null) + if ($util.Long) + (message.integerValue = $util.Long.fromValue(object.integerValue)).unsigned = false; + else if (typeof object.integerValue === "string") + message.integerValue = parseInt(object.integerValue, 10); + else if (typeof object.integerValue === "number") + message.integerValue = object.integerValue; + else if (typeof object.integerValue === "object") + message.integerValue = new $util.LongBits(object.integerValue.low >>> 0, object.integerValue.high >>> 0).toNumber(); + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue); + if (object.timestampValue != null) { + if (typeof object.timestampValue !== "object") + throw TypeError(".google.datastore.v1.Value.timestampValue: object expected"); + message.timestampValue = $root.google.protobuf.Timestamp.fromObject(object.timestampValue); + } + if (object.keyValue != null) { + if (typeof object.keyValue !== "object") + throw TypeError(".google.datastore.v1.Value.keyValue: object expected"); + message.keyValue = $root.google.datastore.v1.Key.fromObject(object.keyValue); + } + if (object.stringValue != null) + message.stringValue = String(object.stringValue); + if (object.blobValue != null) + if (typeof object.blobValue === "string") + $util.base64.decode(object.blobValue, message.blobValue = $util.newBuffer($util.base64.length(object.blobValue)), 0); + else if (object.blobValue.length >= 0) + message.blobValue = object.blobValue; + if (object.geoPointValue != null) { + if (typeof object.geoPointValue !== "object") + throw TypeError(".google.datastore.v1.Value.geoPointValue: object expected"); + message.geoPointValue = $root.google.type.LatLng.fromObject(object.geoPointValue); + } + if (object.entityValue != null) { + if (typeof object.entityValue !== "object") + throw TypeError(".google.datastore.v1.Value.entityValue: object expected"); + message.entityValue = $root.google.datastore.v1.Entity.fromObject(object.entityValue); + } + if (object.arrayValue != null) { + if (typeof object.arrayValue !== "object") + throw TypeError(".google.datastore.v1.Value.arrayValue: object expected"); + message.arrayValue = $root.google.datastore.v1.ArrayValue.fromObject(object.arrayValue); + } + if (object.meaning != null) + message.meaning = object.meaning | 0; + if (object.excludeFromIndexes != null) + message.excludeFromIndexes = Boolean(object.excludeFromIndexes); + return message; + }; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Value + * @static + * @param {google.datastore.v1.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.meaning = 0; + object.excludeFromIndexes = false; + } + if (message.booleanValue != null && message.hasOwnProperty("booleanValue")) { + object.booleanValue = message.booleanValue; + if (options.oneofs) + object.valueType = "booleanValue"; + } + if (message.integerValue != null && message.hasOwnProperty("integerValue")) { + if (typeof message.integerValue === "number") + object.integerValue = options.longs === String ? String(message.integerValue) : message.integerValue; + else + object.integerValue = options.longs === String ? $util.Long.prototype.toString.call(message.integerValue) : options.longs === Number ? new $util.LongBits(message.integerValue.low >>> 0, message.integerValue.high >>> 0).toNumber() : message.integerValue; + if (options.oneofs) + object.valueType = "integerValue"; + } + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) { + object.doubleValue = options.json && !isFinite(message.doubleValue) ? String(message.doubleValue) : message.doubleValue; + if (options.oneofs) + object.valueType = "doubleValue"; + } + if (message.keyValue != null && message.hasOwnProperty("keyValue")) { + object.keyValue = $root.google.datastore.v1.Key.toObject(message.keyValue, options); + if (options.oneofs) + object.valueType = "keyValue"; + } + if (message.entityValue != null && message.hasOwnProperty("entityValue")) { + object.entityValue = $root.google.datastore.v1.Entity.toObject(message.entityValue, options); + if (options.oneofs) + object.valueType = "entityValue"; + } + if (message.geoPointValue != null && message.hasOwnProperty("geoPointValue")) { + object.geoPointValue = $root.google.type.LatLng.toObject(message.geoPointValue, options); + if (options.oneofs) + object.valueType = "geoPointValue"; + } + if (message.arrayValue != null && message.hasOwnProperty("arrayValue")) { + object.arrayValue = $root.google.datastore.v1.ArrayValue.toObject(message.arrayValue, options); + if (options.oneofs) + object.valueType = "arrayValue"; + } + if (message.timestampValue != null && message.hasOwnProperty("timestampValue")) { + object.timestampValue = $root.google.protobuf.Timestamp.toObject(message.timestampValue, options); + if (options.oneofs) + object.valueType = "timestampValue"; + } + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + object.nullValue = options.enums === String ? $root.google.protobuf.NullValue[message.nullValue] === undefined ? message.nullValue : $root.google.protobuf.NullValue[message.nullValue] : message.nullValue; + if (options.oneofs) + object.valueType = "nullValue"; + } + if (message.meaning != null && message.hasOwnProperty("meaning")) + object.meaning = message.meaning; + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + object.stringValue = message.stringValue; + if (options.oneofs) + object.valueType = "stringValue"; + } + if (message.blobValue != null && message.hasOwnProperty("blobValue")) { + object.blobValue = options.bytes === String ? $util.base64.encode(message.blobValue, 0, message.blobValue.length) : options.bytes === Array ? Array.prototype.slice.call(message.blobValue) : message.blobValue; + if (options.oneofs) + object.valueType = "blobValue"; + } + if (message.excludeFromIndexes != null && message.hasOwnProperty("excludeFromIndexes")) + object.excludeFromIndexes = message.excludeFromIndexes; + return object; + }; + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.datastore.v1.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Value + * @function getTypeUrl + * @memberof google.datastore.v1.Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Value"; + }; + + return Value; + })(); + + v1.Entity = (function() { + + /** + * Properties of an Entity. + * @memberof google.datastore.v1 + * @interface IEntity + * @property {google.datastore.v1.IKey|null} [key] Entity key + * @property {Object.|null} [properties] Entity properties + */ + + /** + * Constructs a new Entity. + * @memberof google.datastore.v1 + * @classdesc Represents an Entity. + * @implements IEntity + * @constructor + * @param {google.datastore.v1.IEntity=} [properties] Properties to set + */ + function Entity(properties) { + this.properties = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Entity key. + * @member {google.datastore.v1.IKey|null|undefined} key + * @memberof google.datastore.v1.Entity + * @instance + */ + Entity.prototype.key = null; + + /** + * Entity properties. + * @member {Object.} properties + * @memberof google.datastore.v1.Entity + * @instance + */ + Entity.prototype.properties = $util.emptyObject; + + /** + * Creates a new Entity instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Entity + * @static + * @param {google.datastore.v1.IEntity=} [properties] Properties to set + * @returns {google.datastore.v1.Entity} Entity instance + */ + Entity.create = function create(properties) { + return new Entity(properties); + }; + + /** + * Encodes the specified Entity message. Does not implicitly {@link google.datastore.v1.Entity.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Entity + * @static + * @param {google.datastore.v1.IEntity} message Entity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Entity.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + $root.google.datastore.v1.Key.encode(message.key, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.properties != null && Object.hasOwnProperty.call(message, "properties")) + for (var keys = Object.keys(message.properties), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 3, wireType 2 =*/26).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.datastore.v1.Value.encode(message.properties[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Entity message, length delimited. Does not implicitly {@link google.datastore.v1.Entity.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Entity + * @static + * @param {google.datastore.v1.IEntity} message Entity message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Entity.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Entity message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Entity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Entity} Entity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Entity.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Entity(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.key = $root.google.datastore.v1.Key.decode(reader, reader.uint32()); + break; + } + case 3: { + if (message.properties === $util.emptyObject) + message.properties = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.properties[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Entity message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Entity + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Entity} Entity + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Entity.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Entity message. + * @function verify + * @memberof google.datastore.v1.Entity + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Entity.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) { + var error = $root.google.datastore.v1.Key.verify(message.key); + if (error) + return "key." + error; + } + if (message.properties != null && message.hasOwnProperty("properties")) { + if (!$util.isObject(message.properties)) + return "properties: object expected"; + var key = Object.keys(message.properties); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.datastore.v1.Value.verify(message.properties[key[i]]); + if (error) + return "properties." + error; + } + } + return null; + }; + + /** + * Creates an Entity message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Entity + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Entity} Entity + */ + Entity.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Entity) + return object; + var message = new $root.google.datastore.v1.Entity(); + if (object.key != null) { + if (typeof object.key !== "object") + throw TypeError(".google.datastore.v1.Entity.key: object expected"); + message.key = $root.google.datastore.v1.Key.fromObject(object.key); + } + if (object.properties) { + if (typeof object.properties !== "object") + throw TypeError(".google.datastore.v1.Entity.properties: object expected"); + message.properties = {}; + for (var keys = Object.keys(object.properties), i = 0; i < keys.length; ++i) { + if (typeof object.properties[keys[i]] !== "object") + throw TypeError(".google.datastore.v1.Entity.properties: object expected"); + message.properties[keys[i]] = $root.google.datastore.v1.Value.fromObject(object.properties[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from an Entity message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Entity + * @static + * @param {google.datastore.v1.Entity} message Entity + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Entity.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.properties = {}; + if (options.defaults) + object.key = null; + if (message.key != null && message.hasOwnProperty("key")) + object.key = $root.google.datastore.v1.Key.toObject(message.key, options); + var keys2; + if (message.properties && (keys2 = Object.keys(message.properties)).length) { + object.properties = {}; + for (var j = 0; j < keys2.length; ++j) + object.properties[keys2[j]] = $root.google.datastore.v1.Value.toObject(message.properties[keys2[j]], options); + } + return object; + }; + + /** + * Converts this Entity to JSON. + * @function toJSON + * @memberof google.datastore.v1.Entity + * @instance + * @returns {Object.} JSON object + */ + Entity.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Entity + * @function getTypeUrl + * @memberof google.datastore.v1.Entity + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Entity.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Entity"; + }; + + return Entity; + })(); + + v1.EntityResult = (function() { + + /** + * Properties of an EntityResult. + * @memberof google.datastore.v1 + * @interface IEntityResult + * @property {google.datastore.v1.IEntity|null} [entity] EntityResult entity + * @property {number|Long|null} [version] EntityResult version + * @property {google.protobuf.ITimestamp|null} [createTime] EntityResult createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] EntityResult updateTime + * @property {Uint8Array|null} [cursor] EntityResult cursor + */ + + /** + * Constructs a new EntityResult. + * @memberof google.datastore.v1 + * @classdesc Represents an EntityResult. + * @implements IEntityResult + * @constructor + * @param {google.datastore.v1.IEntityResult=} [properties] Properties to set + */ + function EntityResult(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EntityResult entity. + * @member {google.datastore.v1.IEntity|null|undefined} entity + * @memberof google.datastore.v1.EntityResult + * @instance + */ + EntityResult.prototype.entity = null; + + /** + * EntityResult version. + * @member {number|Long} version + * @memberof google.datastore.v1.EntityResult + * @instance + */ + EntityResult.prototype.version = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * EntityResult createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.datastore.v1.EntityResult + * @instance + */ + EntityResult.prototype.createTime = null; + + /** + * EntityResult updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.datastore.v1.EntityResult + * @instance + */ + EntityResult.prototype.updateTime = null; + + /** + * EntityResult cursor. + * @member {Uint8Array} cursor + * @memberof google.datastore.v1.EntityResult + * @instance + */ + EntityResult.prototype.cursor = $util.newBuffer([]); + + /** + * Creates a new EntityResult instance using the specified properties. + * @function create + * @memberof google.datastore.v1.EntityResult + * @static + * @param {google.datastore.v1.IEntityResult=} [properties] Properties to set + * @returns {google.datastore.v1.EntityResult} EntityResult instance + */ + EntityResult.create = function create(properties) { + return new EntityResult(properties); + }; + + /** + * Encodes the specified EntityResult message. Does not implicitly {@link google.datastore.v1.EntityResult.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.EntityResult + * @static + * @param {google.datastore.v1.IEntityResult} message EntityResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntityResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.entity != null && Object.hasOwnProperty.call(message, "entity")) + $root.google.datastore.v1.Entity.encode(message.entity, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.cursor != null && Object.hasOwnProperty.call(message, "cursor")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.cursor); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.version); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EntityResult message, length delimited. Does not implicitly {@link google.datastore.v1.EntityResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.EntityResult + * @static + * @param {google.datastore.v1.IEntityResult} message EntityResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EntityResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EntityResult message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.EntityResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.EntityResult} EntityResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntityResult.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.EntityResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.entity = $root.google.datastore.v1.Entity.decode(reader, reader.uint32()); + break; + } + case 4: { + message.version = reader.int64(); + break; + } + case 6: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 3: { + message.cursor = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EntityResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.EntityResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.EntityResult} EntityResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EntityResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EntityResult message. + * @function verify + * @memberof google.datastore.v1.EntityResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EntityResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.entity != null && message.hasOwnProperty("entity")) { + var error = $root.google.datastore.v1.Entity.verify(message.entity); + if (error) + return "entity." + error; + } + if (message.version != null && message.hasOwnProperty("version")) + if (!$util.isInteger(message.version) && !(message.version && $util.isInteger(message.version.low) && $util.isInteger(message.version.high))) + return "version: integer|Long expected"; + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.cursor != null && message.hasOwnProperty("cursor")) + if (!(message.cursor && typeof message.cursor.length === "number" || $util.isString(message.cursor))) + return "cursor: buffer expected"; + return null; + }; + + /** + * Creates an EntityResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.EntityResult + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.EntityResult} EntityResult + */ + EntityResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.EntityResult) + return object; + var message = new $root.google.datastore.v1.EntityResult(); + if (object.entity != null) { + if (typeof object.entity !== "object") + throw TypeError(".google.datastore.v1.EntityResult.entity: object expected"); + message.entity = $root.google.datastore.v1.Entity.fromObject(object.entity); + } + if (object.version != null) + if ($util.Long) + (message.version = $util.Long.fromValue(object.version)).unsigned = false; + else if (typeof object.version === "string") + message.version = parseInt(object.version, 10); + else if (typeof object.version === "number") + message.version = object.version; + else if (typeof object.version === "object") + message.version = new $util.LongBits(object.version.low >>> 0, object.version.high >>> 0).toNumber(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.datastore.v1.EntityResult.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.datastore.v1.EntityResult.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.cursor != null) + if (typeof object.cursor === "string") + $util.base64.decode(object.cursor, message.cursor = $util.newBuffer($util.base64.length(object.cursor)), 0); + else if (object.cursor.length >= 0) + message.cursor = object.cursor; + return message; + }; + + /** + * Creates a plain object from an EntityResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.EntityResult + * @static + * @param {google.datastore.v1.EntityResult} message EntityResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EntityResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.entity = null; + if (options.bytes === String) + object.cursor = ""; + else { + object.cursor = []; + if (options.bytes !== Array) + object.cursor = $util.newBuffer(object.cursor); + } + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.version = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.version = options.longs === String ? "0" : 0; + object.updateTime = null; + object.createTime = null; + } + if (message.entity != null && message.hasOwnProperty("entity")) + object.entity = $root.google.datastore.v1.Entity.toObject(message.entity, options); + if (message.cursor != null && message.hasOwnProperty("cursor")) + object.cursor = options.bytes === String ? $util.base64.encode(message.cursor, 0, message.cursor.length) : options.bytes === Array ? Array.prototype.slice.call(message.cursor) : message.cursor; + if (message.version != null && message.hasOwnProperty("version")) + if (typeof message.version === "number") + object.version = options.longs === String ? String(message.version) : message.version; + else + object.version = options.longs === String ? $util.Long.prototype.toString.call(message.version) : options.longs === Number ? new $util.LongBits(message.version.low >>> 0, message.version.high >>> 0).toNumber() : message.version; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + return object; + }; + + /** + * Converts this EntityResult to JSON. + * @function toJSON + * @memberof google.datastore.v1.EntityResult + * @instance + * @returns {Object.} JSON object + */ + EntityResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EntityResult + * @function getTypeUrl + * @memberof google.datastore.v1.EntityResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EntityResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.EntityResult"; + }; + + /** + * ResultType enum. + * @name google.datastore.v1.EntityResult.ResultType + * @enum {number} + * @property {number} RESULT_TYPE_UNSPECIFIED=0 RESULT_TYPE_UNSPECIFIED value + * @property {number} FULL=1 FULL value + * @property {number} PROJECTION=2 PROJECTION value + * @property {number} KEY_ONLY=3 KEY_ONLY value + */ + EntityResult.ResultType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RESULT_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "FULL"] = 1; + values[valuesById[2] = "PROJECTION"] = 2; + values[valuesById[3] = "KEY_ONLY"] = 3; + return values; + })(); + + return EntityResult; + })(); + + v1.Query = (function() { + + /** + * Properties of a Query. + * @memberof google.datastore.v1 + * @interface IQuery + * @property {Array.|null} [projection] Query projection + * @property {Array.|null} [kind] Query kind + * @property {google.datastore.v1.IFilter|null} [filter] Query filter + * @property {Array.|null} [order] Query order + * @property {Array.|null} [distinctOn] Query distinctOn + * @property {Uint8Array|null} [startCursor] Query startCursor + * @property {Uint8Array|null} [endCursor] Query endCursor + * @property {number|null} [offset] Query offset + * @property {google.protobuf.IInt32Value|null} [limit] Query limit + * @property {google.datastore.v1.IFindNearest|null} [findNearest] Query findNearest + */ + + /** + * Constructs a new Query. + * @memberof google.datastore.v1 + * @classdesc Represents a Query. + * @implements IQuery + * @constructor + * @param {google.datastore.v1.IQuery=} [properties] Properties to set + */ + function Query(properties) { + this.projection = []; + this.kind = []; + this.order = []; + this.distinctOn = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Query projection. + * @member {Array.} projection + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.projection = $util.emptyArray; + + /** + * Query kind. + * @member {Array.} kind + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.kind = $util.emptyArray; + + /** + * Query filter. + * @member {google.datastore.v1.IFilter|null|undefined} filter + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.filter = null; + + /** + * Query order. + * @member {Array.} order + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.order = $util.emptyArray; + + /** + * Query distinctOn. + * @member {Array.} distinctOn + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.distinctOn = $util.emptyArray; + + /** + * Query startCursor. + * @member {Uint8Array} startCursor + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.startCursor = $util.newBuffer([]); + + /** + * Query endCursor. + * @member {Uint8Array} endCursor + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.endCursor = $util.newBuffer([]); + + /** + * Query offset. + * @member {number} offset + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.offset = 0; + + /** + * Query limit. + * @member {google.protobuf.IInt32Value|null|undefined} limit + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.limit = null; + + /** + * Query findNearest. + * @member {google.datastore.v1.IFindNearest|null|undefined} findNearest + * @memberof google.datastore.v1.Query + * @instance + */ + Query.prototype.findNearest = null; + + /** + * Creates a new Query instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Query + * @static + * @param {google.datastore.v1.IQuery=} [properties] Properties to set + * @returns {google.datastore.v1.Query} Query instance + */ + Query.create = function create(properties) { + return new Query(properties); + }; + + /** + * Encodes the specified Query message. Does not implicitly {@link google.datastore.v1.Query.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Query + * @static + * @param {google.datastore.v1.IQuery} message Query message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Query.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projection != null && message.projection.length) + for (var i = 0; i < message.projection.length; ++i) + $root.google.datastore.v1.Projection.encode(message.projection[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.kind != null && message.kind.length) + for (var i = 0; i < message.kind.length; ++i) + $root.google.datastore.v1.KindExpression.encode(message.kind[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + $root.google.datastore.v1.Filter.encode(message.filter, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.order != null && message.order.length) + for (var i = 0; i < message.order.length; ++i) + $root.google.datastore.v1.PropertyOrder.encode(message.order[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.distinctOn != null && message.distinctOn.length) + for (var i = 0; i < message.distinctOn.length; ++i) + $root.google.datastore.v1.PropertyReference.encode(message.distinctOn[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.startCursor != null && Object.hasOwnProperty.call(message, "startCursor")) + writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.startCursor); + if (message.endCursor != null && Object.hasOwnProperty.call(message, "endCursor")) + writer.uint32(/* id 8, wireType 2 =*/66).bytes(message.endCursor); + if (message.offset != null && Object.hasOwnProperty.call(message, "offset")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.offset); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + $root.google.protobuf.Int32Value.encode(message.limit, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.findNearest != null && Object.hasOwnProperty.call(message, "findNearest")) + $root.google.datastore.v1.FindNearest.encode(message.findNearest, writer.uint32(/* id 13, wireType 2 =*/106).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Query message, length delimited. Does not implicitly {@link google.datastore.v1.Query.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Query + * @static + * @param {google.datastore.v1.IQuery} message Query message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Query.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Query message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Query + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Query} Query + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Query.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Query(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.projection && message.projection.length)) + message.projection = []; + message.projection.push($root.google.datastore.v1.Projection.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.kind && message.kind.length)) + message.kind = []; + message.kind.push($root.google.datastore.v1.KindExpression.decode(reader, reader.uint32())); + break; + } + case 4: { + message.filter = $root.google.datastore.v1.Filter.decode(reader, reader.uint32()); + break; + } + case 5: { + if (!(message.order && message.order.length)) + message.order = []; + message.order.push($root.google.datastore.v1.PropertyOrder.decode(reader, reader.uint32())); + break; + } + case 6: { + if (!(message.distinctOn && message.distinctOn.length)) + message.distinctOn = []; + message.distinctOn.push($root.google.datastore.v1.PropertyReference.decode(reader, reader.uint32())); + break; + } + case 7: { + message.startCursor = reader.bytes(); + break; + } + case 8: { + message.endCursor = reader.bytes(); + break; + } + case 10: { + message.offset = reader.int32(); + break; + } + case 12: { + message.limit = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + case 13: { + message.findNearest = $root.google.datastore.v1.FindNearest.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Query message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Query + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Query} Query + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Query.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Query message. + * @function verify + * @memberof google.datastore.v1.Query + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Query.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projection != null && message.hasOwnProperty("projection")) { + if (!Array.isArray(message.projection)) + return "projection: array expected"; + for (var i = 0; i < message.projection.length; ++i) { + var error = $root.google.datastore.v1.Projection.verify(message.projection[i]); + if (error) + return "projection." + error; + } + } + if (message.kind != null && message.hasOwnProperty("kind")) { + if (!Array.isArray(message.kind)) + return "kind: array expected"; + for (var i = 0; i < message.kind.length; ++i) { + var error = $root.google.datastore.v1.KindExpression.verify(message.kind[i]); + if (error) + return "kind." + error; + } + } + if (message.filter != null && message.hasOwnProperty("filter")) { + var error = $root.google.datastore.v1.Filter.verify(message.filter); + if (error) + return "filter." + error; + } + if (message.order != null && message.hasOwnProperty("order")) { + if (!Array.isArray(message.order)) + return "order: array expected"; + for (var i = 0; i < message.order.length; ++i) { + var error = $root.google.datastore.v1.PropertyOrder.verify(message.order[i]); + if (error) + return "order." + error; + } + } + if (message.distinctOn != null && message.hasOwnProperty("distinctOn")) { + if (!Array.isArray(message.distinctOn)) + return "distinctOn: array expected"; + for (var i = 0; i < message.distinctOn.length; ++i) { + var error = $root.google.datastore.v1.PropertyReference.verify(message.distinctOn[i]); + if (error) + return "distinctOn." + error; + } + } + if (message.startCursor != null && message.hasOwnProperty("startCursor")) + if (!(message.startCursor && typeof message.startCursor.length === "number" || $util.isString(message.startCursor))) + return "startCursor: buffer expected"; + if (message.endCursor != null && message.hasOwnProperty("endCursor")) + if (!(message.endCursor && typeof message.endCursor.length === "number" || $util.isString(message.endCursor))) + return "endCursor: buffer expected"; + if (message.offset != null && message.hasOwnProperty("offset")) + if (!$util.isInteger(message.offset)) + return "offset: integer expected"; + if (message.limit != null && message.hasOwnProperty("limit")) { + var error = $root.google.protobuf.Int32Value.verify(message.limit); + if (error) + return "limit." + error; + } + if (message.findNearest != null && message.hasOwnProperty("findNearest")) { + var error = $root.google.datastore.v1.FindNearest.verify(message.findNearest); + if (error) + return "findNearest." + error; + } + return null; + }; + + /** + * Creates a Query message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Query + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Query} Query + */ + Query.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Query) + return object; + var message = new $root.google.datastore.v1.Query(); + if (object.projection) { + if (!Array.isArray(object.projection)) + throw TypeError(".google.datastore.v1.Query.projection: array expected"); + message.projection = []; + for (var i = 0; i < object.projection.length; ++i) { + if (typeof object.projection[i] !== "object") + throw TypeError(".google.datastore.v1.Query.projection: object expected"); + message.projection[i] = $root.google.datastore.v1.Projection.fromObject(object.projection[i]); + } + } + if (object.kind) { + if (!Array.isArray(object.kind)) + throw TypeError(".google.datastore.v1.Query.kind: array expected"); + message.kind = []; + for (var i = 0; i < object.kind.length; ++i) { + if (typeof object.kind[i] !== "object") + throw TypeError(".google.datastore.v1.Query.kind: object expected"); + message.kind[i] = $root.google.datastore.v1.KindExpression.fromObject(object.kind[i]); + } + } + if (object.filter != null) { + if (typeof object.filter !== "object") + throw TypeError(".google.datastore.v1.Query.filter: object expected"); + message.filter = $root.google.datastore.v1.Filter.fromObject(object.filter); + } + if (object.order) { + if (!Array.isArray(object.order)) + throw TypeError(".google.datastore.v1.Query.order: array expected"); + message.order = []; + for (var i = 0; i < object.order.length; ++i) { + if (typeof object.order[i] !== "object") + throw TypeError(".google.datastore.v1.Query.order: object expected"); + message.order[i] = $root.google.datastore.v1.PropertyOrder.fromObject(object.order[i]); + } + } + if (object.distinctOn) { + if (!Array.isArray(object.distinctOn)) + throw TypeError(".google.datastore.v1.Query.distinctOn: array expected"); + message.distinctOn = []; + for (var i = 0; i < object.distinctOn.length; ++i) { + if (typeof object.distinctOn[i] !== "object") + throw TypeError(".google.datastore.v1.Query.distinctOn: object expected"); + message.distinctOn[i] = $root.google.datastore.v1.PropertyReference.fromObject(object.distinctOn[i]); + } + } + if (object.startCursor != null) + if (typeof object.startCursor === "string") + $util.base64.decode(object.startCursor, message.startCursor = $util.newBuffer($util.base64.length(object.startCursor)), 0); + else if (object.startCursor.length >= 0) + message.startCursor = object.startCursor; + if (object.endCursor != null) + if (typeof object.endCursor === "string") + $util.base64.decode(object.endCursor, message.endCursor = $util.newBuffer($util.base64.length(object.endCursor)), 0); + else if (object.endCursor.length >= 0) + message.endCursor = object.endCursor; + if (object.offset != null) + message.offset = object.offset | 0; + if (object.limit != null) { + if (typeof object.limit !== "object") + throw TypeError(".google.datastore.v1.Query.limit: object expected"); + message.limit = $root.google.protobuf.Int32Value.fromObject(object.limit); + } + if (object.findNearest != null) { + if (typeof object.findNearest !== "object") + throw TypeError(".google.datastore.v1.Query.findNearest: object expected"); + message.findNearest = $root.google.datastore.v1.FindNearest.fromObject(object.findNearest); + } + return message; + }; + + /** + * Creates a plain object from a Query message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Query + * @static + * @param {google.datastore.v1.Query} message Query + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Query.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.projection = []; + object.kind = []; + object.order = []; + object.distinctOn = []; + } + if (options.defaults) { + object.filter = null; + if (options.bytes === String) + object.startCursor = ""; + else { + object.startCursor = []; + if (options.bytes !== Array) + object.startCursor = $util.newBuffer(object.startCursor); + } + if (options.bytes === String) + object.endCursor = ""; + else { + object.endCursor = []; + if (options.bytes !== Array) + object.endCursor = $util.newBuffer(object.endCursor); + } + object.offset = 0; + object.limit = null; + object.findNearest = null; + } + if (message.projection && message.projection.length) { + object.projection = []; + for (var j = 0; j < message.projection.length; ++j) + object.projection[j] = $root.google.datastore.v1.Projection.toObject(message.projection[j], options); + } + if (message.kind && message.kind.length) { + object.kind = []; + for (var j = 0; j < message.kind.length; ++j) + object.kind[j] = $root.google.datastore.v1.KindExpression.toObject(message.kind[j], options); + } + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = $root.google.datastore.v1.Filter.toObject(message.filter, options); + if (message.order && message.order.length) { + object.order = []; + for (var j = 0; j < message.order.length; ++j) + object.order[j] = $root.google.datastore.v1.PropertyOrder.toObject(message.order[j], options); + } + if (message.distinctOn && message.distinctOn.length) { + object.distinctOn = []; + for (var j = 0; j < message.distinctOn.length; ++j) + object.distinctOn[j] = $root.google.datastore.v1.PropertyReference.toObject(message.distinctOn[j], options); + } + if (message.startCursor != null && message.hasOwnProperty("startCursor")) + object.startCursor = options.bytes === String ? $util.base64.encode(message.startCursor, 0, message.startCursor.length) : options.bytes === Array ? Array.prototype.slice.call(message.startCursor) : message.startCursor; + if (message.endCursor != null && message.hasOwnProperty("endCursor")) + object.endCursor = options.bytes === String ? $util.base64.encode(message.endCursor, 0, message.endCursor.length) : options.bytes === Array ? Array.prototype.slice.call(message.endCursor) : message.endCursor; + if (message.offset != null && message.hasOwnProperty("offset")) + object.offset = message.offset; + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = $root.google.protobuf.Int32Value.toObject(message.limit, options); + if (message.findNearest != null && message.hasOwnProperty("findNearest")) + object.findNearest = $root.google.datastore.v1.FindNearest.toObject(message.findNearest, options); + return object; + }; + + /** + * Converts this Query to JSON. + * @function toJSON + * @memberof google.datastore.v1.Query + * @instance + * @returns {Object.} JSON object + */ + Query.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Query + * @function getTypeUrl + * @memberof google.datastore.v1.Query + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Query.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Query"; + }; + + return Query; + })(); + + v1.AggregationQuery = (function() { + + /** + * Properties of an AggregationQuery. + * @memberof google.datastore.v1 + * @interface IAggregationQuery + * @property {google.datastore.v1.IQuery|null} [nestedQuery] AggregationQuery nestedQuery + * @property {Array.|null} [aggregations] AggregationQuery aggregations + */ + + /** + * Constructs a new AggregationQuery. + * @memberof google.datastore.v1 + * @classdesc Represents an AggregationQuery. + * @implements IAggregationQuery + * @constructor + * @param {google.datastore.v1.IAggregationQuery=} [properties] Properties to set + */ + function AggregationQuery(properties) { + this.aggregations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * AggregationQuery nestedQuery. + * @member {google.datastore.v1.IQuery|null|undefined} nestedQuery + * @memberof google.datastore.v1.AggregationQuery + * @instance + */ + AggregationQuery.prototype.nestedQuery = null; + + /** + * AggregationQuery aggregations. + * @member {Array.} aggregations + * @memberof google.datastore.v1.AggregationQuery + * @instance + */ + AggregationQuery.prototype.aggregations = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * AggregationQuery queryType. + * @member {"nestedQuery"|undefined} queryType + * @memberof google.datastore.v1.AggregationQuery + * @instance + */ + Object.defineProperty(AggregationQuery.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["nestedQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new AggregationQuery instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {google.datastore.v1.IAggregationQuery=} [properties] Properties to set + * @returns {google.datastore.v1.AggregationQuery} AggregationQuery instance + */ + AggregationQuery.create = function create(properties) { + return new AggregationQuery(properties); + }; + + /** + * Encodes the specified AggregationQuery message. Does not implicitly {@link google.datastore.v1.AggregationQuery.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {google.datastore.v1.IAggregationQuery} message AggregationQuery message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AggregationQuery.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.nestedQuery != null && Object.hasOwnProperty.call(message, "nestedQuery")) + $root.google.datastore.v1.Query.encode(message.nestedQuery, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.aggregations != null && message.aggregations.length) + for (var i = 0; i < message.aggregations.length; ++i) + $root.google.datastore.v1.AggregationQuery.Aggregation.encode(message.aggregations[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AggregationQuery message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {google.datastore.v1.IAggregationQuery} message AggregationQuery message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AggregationQuery.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AggregationQuery message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AggregationQuery} AggregationQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AggregationQuery.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AggregationQuery(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.nestedQuery = $root.google.datastore.v1.Query.decode(reader, reader.uint32()); + break; + } + case 3: { + if (!(message.aggregations && message.aggregations.length)) + message.aggregations = []; + message.aggregations.push($root.google.datastore.v1.AggregationQuery.Aggregation.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AggregationQuery message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AggregationQuery} AggregationQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AggregationQuery.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AggregationQuery message. + * @function verify + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AggregationQuery.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.nestedQuery != null && message.hasOwnProperty("nestedQuery")) { + properties.queryType = 1; + { + var error = $root.google.datastore.v1.Query.verify(message.nestedQuery); + if (error) + return "nestedQuery." + error; + } + } + if (message.aggregations != null && message.hasOwnProperty("aggregations")) { + if (!Array.isArray(message.aggregations)) + return "aggregations: array expected"; + for (var i = 0; i < message.aggregations.length; ++i) { + var error = $root.google.datastore.v1.AggregationQuery.Aggregation.verify(message.aggregations[i]); + if (error) + return "aggregations." + error; + } + } + return null; + }; + + /** + * Creates an AggregationQuery message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AggregationQuery} AggregationQuery + */ + AggregationQuery.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AggregationQuery) + return object; + var message = new $root.google.datastore.v1.AggregationQuery(); + if (object.nestedQuery != null) { + if (typeof object.nestedQuery !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.nestedQuery: object expected"); + message.nestedQuery = $root.google.datastore.v1.Query.fromObject(object.nestedQuery); + } + if (object.aggregations) { + if (!Array.isArray(object.aggregations)) + throw TypeError(".google.datastore.v1.AggregationQuery.aggregations: array expected"); + message.aggregations = []; + for (var i = 0; i < object.aggregations.length; ++i) { + if (typeof object.aggregations[i] !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.aggregations: object expected"); + message.aggregations[i] = $root.google.datastore.v1.AggregationQuery.Aggregation.fromObject(object.aggregations[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an AggregationQuery message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {google.datastore.v1.AggregationQuery} message AggregationQuery + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AggregationQuery.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.aggregations = []; + if (message.nestedQuery != null && message.hasOwnProperty("nestedQuery")) { + object.nestedQuery = $root.google.datastore.v1.Query.toObject(message.nestedQuery, options); + if (options.oneofs) + object.queryType = "nestedQuery"; + } + if (message.aggregations && message.aggregations.length) { + object.aggregations = []; + for (var j = 0; j < message.aggregations.length; ++j) + object.aggregations[j] = $root.google.datastore.v1.AggregationQuery.Aggregation.toObject(message.aggregations[j], options); + } + return object; + }; + + /** + * Converts this AggregationQuery to JSON. + * @function toJSON + * @memberof google.datastore.v1.AggregationQuery + * @instance + * @returns {Object.} JSON object + */ + AggregationQuery.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AggregationQuery + * @function getTypeUrl + * @memberof google.datastore.v1.AggregationQuery + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AggregationQuery.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AggregationQuery"; + }; + + AggregationQuery.Aggregation = (function() { + + /** + * Properties of an Aggregation. + * @memberof google.datastore.v1.AggregationQuery + * @interface IAggregation + * @property {google.datastore.v1.AggregationQuery.Aggregation.ICount|null} [count] Aggregation count + * @property {google.datastore.v1.AggregationQuery.Aggregation.ISum|null} [sum] Aggregation sum + * @property {google.datastore.v1.AggregationQuery.Aggregation.IAvg|null} [avg] Aggregation avg + * @property {string|null} [alias] Aggregation alias + */ + + /** + * Constructs a new Aggregation. + * @memberof google.datastore.v1.AggregationQuery + * @classdesc Represents an Aggregation. + * @implements IAggregation + * @constructor + * @param {google.datastore.v1.AggregationQuery.IAggregation=} [properties] Properties to set + */ + function Aggregation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Aggregation count. + * @member {google.datastore.v1.AggregationQuery.Aggregation.ICount|null|undefined} count + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @instance + */ + Aggregation.prototype.count = null; + + /** + * Aggregation sum. + * @member {google.datastore.v1.AggregationQuery.Aggregation.ISum|null|undefined} sum + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @instance + */ + Aggregation.prototype.sum = null; + + /** + * Aggregation avg. + * @member {google.datastore.v1.AggregationQuery.Aggregation.IAvg|null|undefined} avg + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @instance + */ + Aggregation.prototype.avg = null; + + /** + * Aggregation alias. + * @member {string} alias + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @instance + */ + Aggregation.prototype.alias = ""; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Aggregation operator. + * @member {"count"|"sum"|"avg"|undefined} operator + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @instance + */ + Object.defineProperty(Aggregation.prototype, "operator", { + get: $util.oneOfGetter($oneOfFields = ["count", "sum", "avg"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Aggregation instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {google.datastore.v1.AggregationQuery.IAggregation=} [properties] Properties to set + * @returns {google.datastore.v1.AggregationQuery.Aggregation} Aggregation instance + */ + Aggregation.create = function create(properties) { + return new Aggregation(properties); + }; + + /** + * Encodes the specified Aggregation message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {google.datastore.v1.AggregationQuery.IAggregation} message Aggregation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Aggregation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.count != null && Object.hasOwnProperty.call(message, "count")) + $root.google.datastore.v1.AggregationQuery.Aggregation.Count.encode(message.count, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.sum != null && Object.hasOwnProperty.call(message, "sum")) + $root.google.datastore.v1.AggregationQuery.Aggregation.Sum.encode(message.sum, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.avg != null && Object.hasOwnProperty.call(message, "avg")) + $root.google.datastore.v1.AggregationQuery.Aggregation.Avg.encode(message.avg, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.alias != null && Object.hasOwnProperty.call(message, "alias")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.alias); + return writer; + }; + + /** + * Encodes the specified Aggregation message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {google.datastore.v1.AggregationQuery.IAggregation} message Aggregation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Aggregation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Aggregation message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AggregationQuery.Aggregation} Aggregation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Aggregation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AggregationQuery.Aggregation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.count = $root.google.datastore.v1.AggregationQuery.Aggregation.Count.decode(reader, reader.uint32()); + break; + } + case 2: { + message.sum = $root.google.datastore.v1.AggregationQuery.Aggregation.Sum.decode(reader, reader.uint32()); + break; + } + case 3: { + message.avg = $root.google.datastore.v1.AggregationQuery.Aggregation.Avg.decode(reader, reader.uint32()); + break; + } + case 7: { + message.alias = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Aggregation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AggregationQuery.Aggregation} Aggregation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Aggregation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Aggregation message. + * @function verify + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Aggregation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.count != null && message.hasOwnProperty("count")) { + properties.operator = 1; + { + var error = $root.google.datastore.v1.AggregationQuery.Aggregation.Count.verify(message.count); + if (error) + return "count." + error; + } + } + if (message.sum != null && message.hasOwnProperty("sum")) { + if (properties.operator === 1) + return "operator: multiple values"; + properties.operator = 1; + { + var error = $root.google.datastore.v1.AggregationQuery.Aggregation.Sum.verify(message.sum); + if (error) + return "sum." + error; + } + } + if (message.avg != null && message.hasOwnProperty("avg")) { + if (properties.operator === 1) + return "operator: multiple values"; + properties.operator = 1; + { + var error = $root.google.datastore.v1.AggregationQuery.Aggregation.Avg.verify(message.avg); + if (error) + return "avg." + error; + } + } + if (message.alias != null && message.hasOwnProperty("alias")) + if (!$util.isString(message.alias)) + return "alias: string expected"; + return null; + }; + + /** + * Creates an Aggregation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AggregationQuery.Aggregation} Aggregation + */ + Aggregation.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AggregationQuery.Aggregation) + return object; + var message = new $root.google.datastore.v1.AggregationQuery.Aggregation(); + if (object.count != null) { + if (typeof object.count !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.Aggregation.count: object expected"); + message.count = $root.google.datastore.v1.AggregationQuery.Aggregation.Count.fromObject(object.count); + } + if (object.sum != null) { + if (typeof object.sum !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.Aggregation.sum: object expected"); + message.sum = $root.google.datastore.v1.AggregationQuery.Aggregation.Sum.fromObject(object.sum); + } + if (object.avg != null) { + if (typeof object.avg !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.Aggregation.avg: object expected"); + message.avg = $root.google.datastore.v1.AggregationQuery.Aggregation.Avg.fromObject(object.avg); + } + if (object.alias != null) + message.alias = String(object.alias); + return message; + }; + + /** + * Creates a plain object from an Aggregation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation} message Aggregation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Aggregation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.alias = ""; + if (message.count != null && message.hasOwnProperty("count")) { + object.count = $root.google.datastore.v1.AggregationQuery.Aggregation.Count.toObject(message.count, options); + if (options.oneofs) + object.operator = "count"; + } + if (message.sum != null && message.hasOwnProperty("sum")) { + object.sum = $root.google.datastore.v1.AggregationQuery.Aggregation.Sum.toObject(message.sum, options); + if (options.oneofs) + object.operator = "sum"; + } + if (message.avg != null && message.hasOwnProperty("avg")) { + object.avg = $root.google.datastore.v1.AggregationQuery.Aggregation.Avg.toObject(message.avg, options); + if (options.oneofs) + object.operator = "avg"; + } + if (message.alias != null && message.hasOwnProperty("alias")) + object.alias = message.alias; + return object; + }; + + /** + * Converts this Aggregation to JSON. + * @function toJSON + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @instance + * @returns {Object.} JSON object + */ + Aggregation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Aggregation + * @function getTypeUrl + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Aggregation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AggregationQuery.Aggregation"; + }; + + Aggregation.Count = (function() { + + /** + * Properties of a Count. + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @interface ICount + * @property {google.protobuf.IInt64Value|null} [upTo] Count upTo + */ + + /** + * Constructs a new Count. + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @classdesc Represents a Count. + * @implements ICount + * @constructor + * @param {google.datastore.v1.AggregationQuery.Aggregation.ICount=} [properties] Properties to set + */ + function Count(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Count upTo. + * @member {google.protobuf.IInt64Value|null|undefined} upTo + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @instance + */ + Count.prototype.upTo = null; + + /** + * Creates a new Count instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.ICount=} [properties] Properties to set + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Count} Count instance + */ + Count.create = function create(properties) { + return new Count(properties); + }; + + /** + * Encodes the specified Count message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Count.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.ICount} message Count message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Count.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.upTo != null && Object.hasOwnProperty.call(message, "upTo")) + $root.google.protobuf.Int64Value.encode(message.upTo, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Count message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Count.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.ICount} message Count message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Count.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Count message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Count} Count + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Count.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AggregationQuery.Aggregation.Count(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.upTo = $root.google.protobuf.Int64Value.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Count message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Count} Count + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Count.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Count message. + * @function verify + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Count.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.upTo != null && message.hasOwnProperty("upTo")) { + var error = $root.google.protobuf.Int64Value.verify(message.upTo); + if (error) + return "upTo." + error; + } + return null; + }; + + /** + * Creates a Count message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Count} Count + */ + Count.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AggregationQuery.Aggregation.Count) + return object; + var message = new $root.google.datastore.v1.AggregationQuery.Aggregation.Count(); + if (object.upTo != null) { + if (typeof object.upTo !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.Aggregation.Count.upTo: object expected"); + message.upTo = $root.google.protobuf.Int64Value.fromObject(object.upTo); + } + return message; + }; + + /** + * Creates a plain object from a Count message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.Count} message Count + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Count.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.upTo = null; + if (message.upTo != null && message.hasOwnProperty("upTo")) + object.upTo = $root.google.protobuf.Int64Value.toObject(message.upTo, options); + return object; + }; + + /** + * Converts this Count to JSON. + * @function toJSON + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @instance + * @returns {Object.} JSON object + */ + Count.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Count + * @function getTypeUrl + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Count + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Count.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AggregationQuery.Aggregation.Count"; + }; + + return Count; + })(); + + Aggregation.Sum = (function() { + + /** + * Properties of a Sum. + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @interface ISum + * @property {google.datastore.v1.IPropertyReference|null} [property] Sum property + */ + + /** + * Constructs a new Sum. + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @classdesc Represents a Sum. + * @implements ISum + * @constructor + * @param {google.datastore.v1.AggregationQuery.Aggregation.ISum=} [properties] Properties to set + */ + function Sum(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Sum property. + * @member {google.datastore.v1.IPropertyReference|null|undefined} property + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @instance + */ + Sum.prototype.property = null; + + /** + * Creates a new Sum instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.ISum=} [properties] Properties to set + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Sum} Sum instance + */ + Sum.create = function create(properties) { + return new Sum(properties); + }; + + /** + * Encodes the specified Sum message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Sum.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.ISum} message Sum message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Sum.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.property != null && Object.hasOwnProperty.call(message, "property")) + $root.google.datastore.v1.PropertyReference.encode(message.property, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Sum message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Sum.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.ISum} message Sum message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Sum.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Sum message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Sum} Sum + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Sum.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AggregationQuery.Aggregation.Sum(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.property = $root.google.datastore.v1.PropertyReference.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Sum message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Sum} Sum + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Sum.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Sum message. + * @function verify + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Sum.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.property != null && message.hasOwnProperty("property")) { + var error = $root.google.datastore.v1.PropertyReference.verify(message.property); + if (error) + return "property." + error; + } + return null; + }; + + /** + * Creates a Sum message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Sum} Sum + */ + Sum.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AggregationQuery.Aggregation.Sum) + return object; + var message = new $root.google.datastore.v1.AggregationQuery.Aggregation.Sum(); + if (object.property != null) { + if (typeof object.property !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.Aggregation.Sum.property: object expected"); + message.property = $root.google.datastore.v1.PropertyReference.fromObject(object.property); + } + return message; + }; + + /** + * Creates a plain object from a Sum message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.Sum} message Sum + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Sum.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.property = null; + if (message.property != null && message.hasOwnProperty("property")) + object.property = $root.google.datastore.v1.PropertyReference.toObject(message.property, options); + return object; + }; + + /** + * Converts this Sum to JSON. + * @function toJSON + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @instance + * @returns {Object.} JSON object + */ + Sum.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Sum + * @function getTypeUrl + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Sum + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Sum.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AggregationQuery.Aggregation.Sum"; + }; + + return Sum; + })(); + + Aggregation.Avg = (function() { + + /** + * Properties of an Avg. + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @interface IAvg + * @property {google.datastore.v1.IPropertyReference|null} [property] Avg property + */ + + /** + * Constructs a new Avg. + * @memberof google.datastore.v1.AggregationQuery.Aggregation + * @classdesc Represents an Avg. + * @implements IAvg + * @constructor + * @param {google.datastore.v1.AggregationQuery.Aggregation.IAvg=} [properties] Properties to set + */ + function Avg(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Avg property. + * @member {google.datastore.v1.IPropertyReference|null|undefined} property + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @instance + */ + Avg.prototype.property = null; + + /** + * Creates a new Avg instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.IAvg=} [properties] Properties to set + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Avg} Avg instance + */ + Avg.create = function create(properties) { + return new Avg(properties); + }; + + /** + * Encodes the specified Avg message. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Avg.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.IAvg} message Avg message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Avg.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.property != null && Object.hasOwnProperty.call(message, "property")) + $root.google.datastore.v1.PropertyReference.encode(message.property, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Avg message, length delimited. Does not implicitly {@link google.datastore.v1.AggregationQuery.Aggregation.Avg.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.IAvg} message Avg message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Avg.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Avg message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Avg} Avg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Avg.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AggregationQuery.Aggregation.Avg(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.property = $root.google.datastore.v1.PropertyReference.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Avg message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Avg} Avg + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Avg.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Avg message. + * @function verify + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Avg.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.property != null && message.hasOwnProperty("property")) { + var error = $root.google.datastore.v1.PropertyReference.verify(message.property); + if (error) + return "property." + error; + } + return null; + }; + + /** + * Creates an Avg message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AggregationQuery.Aggregation.Avg} Avg + */ + Avg.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AggregationQuery.Aggregation.Avg) + return object; + var message = new $root.google.datastore.v1.AggregationQuery.Aggregation.Avg(); + if (object.property != null) { + if (typeof object.property !== "object") + throw TypeError(".google.datastore.v1.AggregationQuery.Aggregation.Avg.property: object expected"); + message.property = $root.google.datastore.v1.PropertyReference.fromObject(object.property); + } + return message; + }; + + /** + * Creates a plain object from an Avg message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {google.datastore.v1.AggregationQuery.Aggregation.Avg} message Avg + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Avg.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.property = null; + if (message.property != null && message.hasOwnProperty("property")) + object.property = $root.google.datastore.v1.PropertyReference.toObject(message.property, options); + return object; + }; + + /** + * Converts this Avg to JSON. + * @function toJSON + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @instance + * @returns {Object.} JSON object + */ + Avg.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Avg + * @function getTypeUrl + * @memberof google.datastore.v1.AggregationQuery.Aggregation.Avg + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Avg.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AggregationQuery.Aggregation.Avg"; + }; + + return Avg; + })(); + + return Aggregation; + })(); + + return AggregationQuery; + })(); + + v1.KindExpression = (function() { + + /** + * Properties of a KindExpression. + * @memberof google.datastore.v1 + * @interface IKindExpression + * @property {string|null} [name] KindExpression name + */ + + /** + * Constructs a new KindExpression. + * @memberof google.datastore.v1 + * @classdesc Represents a KindExpression. + * @implements IKindExpression + * @constructor + * @param {google.datastore.v1.IKindExpression=} [properties] Properties to set + */ + function KindExpression(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * KindExpression name. + * @member {string} name + * @memberof google.datastore.v1.KindExpression + * @instance + */ + KindExpression.prototype.name = ""; + + /** + * Creates a new KindExpression instance using the specified properties. + * @function create + * @memberof google.datastore.v1.KindExpression + * @static + * @param {google.datastore.v1.IKindExpression=} [properties] Properties to set + * @returns {google.datastore.v1.KindExpression} KindExpression instance + */ + KindExpression.create = function create(properties) { + return new KindExpression(properties); + }; + + /** + * Encodes the specified KindExpression message. Does not implicitly {@link google.datastore.v1.KindExpression.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.KindExpression + * @static + * @param {google.datastore.v1.IKindExpression} message KindExpression message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KindExpression.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified KindExpression message, length delimited. Does not implicitly {@link google.datastore.v1.KindExpression.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.KindExpression + * @static + * @param {google.datastore.v1.IKindExpression} message KindExpression message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + KindExpression.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a KindExpression message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.KindExpression + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.KindExpression} KindExpression + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KindExpression.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.KindExpression(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a KindExpression message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.KindExpression + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.KindExpression} KindExpression + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + KindExpression.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a KindExpression message. + * @function verify + * @memberof google.datastore.v1.KindExpression + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + KindExpression.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a KindExpression message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.KindExpression + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.KindExpression} KindExpression + */ + KindExpression.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.KindExpression) + return object; + var message = new $root.google.datastore.v1.KindExpression(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a KindExpression message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.KindExpression + * @static + * @param {google.datastore.v1.KindExpression} message KindExpression + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + KindExpression.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this KindExpression to JSON. + * @function toJSON + * @memberof google.datastore.v1.KindExpression + * @instance + * @returns {Object.} JSON object + */ + KindExpression.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for KindExpression + * @function getTypeUrl + * @memberof google.datastore.v1.KindExpression + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + KindExpression.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.KindExpression"; + }; + + return KindExpression; + })(); + + v1.PropertyReference = (function() { + + /** + * Properties of a PropertyReference. + * @memberof google.datastore.v1 + * @interface IPropertyReference + * @property {string|null} [name] PropertyReference name + */ + + /** + * Constructs a new PropertyReference. + * @memberof google.datastore.v1 + * @classdesc Represents a PropertyReference. + * @implements IPropertyReference + * @constructor + * @param {google.datastore.v1.IPropertyReference=} [properties] Properties to set + */ + function PropertyReference(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PropertyReference name. + * @member {string} name + * @memberof google.datastore.v1.PropertyReference + * @instance + */ + PropertyReference.prototype.name = ""; + + /** + * Creates a new PropertyReference instance using the specified properties. + * @function create + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {google.datastore.v1.IPropertyReference=} [properties] Properties to set + * @returns {google.datastore.v1.PropertyReference} PropertyReference instance + */ + PropertyReference.create = function create(properties) { + return new PropertyReference(properties); + }; + + /** + * Encodes the specified PropertyReference message. Does not implicitly {@link google.datastore.v1.PropertyReference.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {google.datastore.v1.IPropertyReference} message PropertyReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyReference.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.name); + return writer; + }; + + /** + * Encodes the specified PropertyReference message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyReference.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {google.datastore.v1.IPropertyReference} message PropertyReference message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyReference.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PropertyReference message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.PropertyReference} PropertyReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyReference.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.PropertyReference(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PropertyReference message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.PropertyReference} PropertyReference + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyReference.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PropertyReference message. + * @function verify + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PropertyReference.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a PropertyReference message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.PropertyReference} PropertyReference + */ + PropertyReference.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.PropertyReference) + return object; + var message = new $root.google.datastore.v1.PropertyReference(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a PropertyReference message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {google.datastore.v1.PropertyReference} message PropertyReference + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PropertyReference.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this PropertyReference to JSON. + * @function toJSON + * @memberof google.datastore.v1.PropertyReference + * @instance + * @returns {Object.} JSON object + */ + PropertyReference.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PropertyReference + * @function getTypeUrl + * @memberof google.datastore.v1.PropertyReference + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PropertyReference.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.PropertyReference"; + }; + + return PropertyReference; + })(); + + v1.Projection = (function() { + + /** + * Properties of a Projection. + * @memberof google.datastore.v1 + * @interface IProjection + * @property {google.datastore.v1.IPropertyReference|null} [property] Projection property + */ + + /** + * Constructs a new Projection. + * @memberof google.datastore.v1 + * @classdesc Represents a Projection. + * @implements IProjection + * @constructor + * @param {google.datastore.v1.IProjection=} [properties] Properties to set + */ + function Projection(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Projection property. + * @member {google.datastore.v1.IPropertyReference|null|undefined} property + * @memberof google.datastore.v1.Projection + * @instance + */ + Projection.prototype.property = null; + + /** + * Creates a new Projection instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Projection + * @static + * @param {google.datastore.v1.IProjection=} [properties] Properties to set + * @returns {google.datastore.v1.Projection} Projection instance + */ + Projection.create = function create(properties) { + return new Projection(properties); + }; + + /** + * Encodes the specified Projection message. Does not implicitly {@link google.datastore.v1.Projection.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Projection + * @static + * @param {google.datastore.v1.IProjection} message Projection message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Projection.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.property != null && Object.hasOwnProperty.call(message, "property")) + $root.google.datastore.v1.PropertyReference.encode(message.property, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Projection message, length delimited. Does not implicitly {@link google.datastore.v1.Projection.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Projection + * @static + * @param {google.datastore.v1.IProjection} message Projection message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Projection.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Projection message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Projection + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Projection} Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Projection.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Projection(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.property = $root.google.datastore.v1.PropertyReference.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Projection message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Projection + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Projection} Projection + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Projection.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Projection message. + * @function verify + * @memberof google.datastore.v1.Projection + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Projection.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.property != null && message.hasOwnProperty("property")) { + var error = $root.google.datastore.v1.PropertyReference.verify(message.property); + if (error) + return "property." + error; + } + return null; + }; + + /** + * Creates a Projection message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Projection + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Projection} Projection + */ + Projection.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Projection) + return object; + var message = new $root.google.datastore.v1.Projection(); + if (object.property != null) { + if (typeof object.property !== "object") + throw TypeError(".google.datastore.v1.Projection.property: object expected"); + message.property = $root.google.datastore.v1.PropertyReference.fromObject(object.property); + } + return message; + }; + + /** + * Creates a plain object from a Projection message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Projection + * @static + * @param {google.datastore.v1.Projection} message Projection + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Projection.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.property = null; + if (message.property != null && message.hasOwnProperty("property")) + object.property = $root.google.datastore.v1.PropertyReference.toObject(message.property, options); + return object; + }; + + /** + * Converts this Projection to JSON. + * @function toJSON + * @memberof google.datastore.v1.Projection + * @instance + * @returns {Object.} JSON object + */ + Projection.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Projection + * @function getTypeUrl + * @memberof google.datastore.v1.Projection + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Projection.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Projection"; + }; + + return Projection; + })(); + + v1.PropertyOrder = (function() { + + /** + * Properties of a PropertyOrder. + * @memberof google.datastore.v1 + * @interface IPropertyOrder + * @property {google.datastore.v1.IPropertyReference|null} [property] PropertyOrder property + * @property {google.datastore.v1.PropertyOrder.Direction|null} [direction] PropertyOrder direction + */ + + /** + * Constructs a new PropertyOrder. + * @memberof google.datastore.v1 + * @classdesc Represents a PropertyOrder. + * @implements IPropertyOrder + * @constructor + * @param {google.datastore.v1.IPropertyOrder=} [properties] Properties to set + */ + function PropertyOrder(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PropertyOrder property. + * @member {google.datastore.v1.IPropertyReference|null|undefined} property + * @memberof google.datastore.v1.PropertyOrder + * @instance + */ + PropertyOrder.prototype.property = null; + + /** + * PropertyOrder direction. + * @member {google.datastore.v1.PropertyOrder.Direction} direction + * @memberof google.datastore.v1.PropertyOrder + * @instance + */ + PropertyOrder.prototype.direction = 0; + + /** + * Creates a new PropertyOrder instance using the specified properties. + * @function create + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {google.datastore.v1.IPropertyOrder=} [properties] Properties to set + * @returns {google.datastore.v1.PropertyOrder} PropertyOrder instance + */ + PropertyOrder.create = function create(properties) { + return new PropertyOrder(properties); + }; + + /** + * Encodes the specified PropertyOrder message. Does not implicitly {@link google.datastore.v1.PropertyOrder.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {google.datastore.v1.IPropertyOrder} message PropertyOrder message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyOrder.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.property != null && Object.hasOwnProperty.call(message, "property")) + $root.google.datastore.v1.PropertyReference.encode(message.property, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.direction != null && Object.hasOwnProperty.call(message, "direction")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.direction); + return writer; + }; + + /** + * Encodes the specified PropertyOrder message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyOrder.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {google.datastore.v1.IPropertyOrder} message PropertyOrder message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyOrder.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PropertyOrder message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.PropertyOrder} PropertyOrder + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyOrder.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.PropertyOrder(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.property = $root.google.datastore.v1.PropertyReference.decode(reader, reader.uint32()); + break; + } + case 2: { + message.direction = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PropertyOrder message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.PropertyOrder} PropertyOrder + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyOrder.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PropertyOrder message. + * @function verify + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PropertyOrder.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.property != null && message.hasOwnProperty("property")) { + var error = $root.google.datastore.v1.PropertyReference.verify(message.property); + if (error) + return "property." + error; + } + if (message.direction != null && message.hasOwnProperty("direction")) + switch (message.direction) { + default: + return "direction: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a PropertyOrder message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.PropertyOrder} PropertyOrder + */ + PropertyOrder.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.PropertyOrder) + return object; + var message = new $root.google.datastore.v1.PropertyOrder(); + if (object.property != null) { + if (typeof object.property !== "object") + throw TypeError(".google.datastore.v1.PropertyOrder.property: object expected"); + message.property = $root.google.datastore.v1.PropertyReference.fromObject(object.property); + } + switch (object.direction) { + default: + if (typeof object.direction === "number") { + message.direction = object.direction; + break; + } + break; + case "DIRECTION_UNSPECIFIED": + case 0: + message.direction = 0; + break; + case "ASCENDING": + case 1: + message.direction = 1; + break; + case "DESCENDING": + case 2: + message.direction = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a PropertyOrder message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {google.datastore.v1.PropertyOrder} message PropertyOrder + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PropertyOrder.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.property = null; + object.direction = options.enums === String ? "DIRECTION_UNSPECIFIED" : 0; + } + if (message.property != null && message.hasOwnProperty("property")) + object.property = $root.google.datastore.v1.PropertyReference.toObject(message.property, options); + if (message.direction != null && message.hasOwnProperty("direction")) + object.direction = options.enums === String ? $root.google.datastore.v1.PropertyOrder.Direction[message.direction] === undefined ? message.direction : $root.google.datastore.v1.PropertyOrder.Direction[message.direction] : message.direction; + return object; + }; + + /** + * Converts this PropertyOrder to JSON. + * @function toJSON + * @memberof google.datastore.v1.PropertyOrder + * @instance + * @returns {Object.} JSON object + */ + PropertyOrder.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PropertyOrder + * @function getTypeUrl + * @memberof google.datastore.v1.PropertyOrder + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PropertyOrder.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.PropertyOrder"; + }; + + /** + * Direction enum. + * @name google.datastore.v1.PropertyOrder.Direction + * @enum {number} + * @property {number} DIRECTION_UNSPECIFIED=0 DIRECTION_UNSPECIFIED value + * @property {number} ASCENDING=1 ASCENDING value + * @property {number} DESCENDING=2 DESCENDING value + */ + PropertyOrder.Direction = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DIRECTION_UNSPECIFIED"] = 0; + values[valuesById[1] = "ASCENDING"] = 1; + values[valuesById[2] = "DESCENDING"] = 2; + return values; + })(); + + return PropertyOrder; + })(); + + v1.Filter = (function() { + + /** + * Properties of a Filter. + * @memberof google.datastore.v1 + * @interface IFilter + * @property {google.datastore.v1.ICompositeFilter|null} [compositeFilter] Filter compositeFilter + * @property {google.datastore.v1.IPropertyFilter|null} [propertyFilter] Filter propertyFilter + */ + + /** + * Constructs a new Filter. + * @memberof google.datastore.v1 + * @classdesc Represents a Filter. + * @implements IFilter + * @constructor + * @param {google.datastore.v1.IFilter=} [properties] Properties to set + */ + function Filter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Filter compositeFilter. + * @member {google.datastore.v1.ICompositeFilter|null|undefined} compositeFilter + * @memberof google.datastore.v1.Filter + * @instance + */ + Filter.prototype.compositeFilter = null; + + /** + * Filter propertyFilter. + * @member {google.datastore.v1.IPropertyFilter|null|undefined} propertyFilter + * @memberof google.datastore.v1.Filter + * @instance + */ + Filter.prototype.propertyFilter = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Filter filterType. + * @member {"compositeFilter"|"propertyFilter"|undefined} filterType + * @memberof google.datastore.v1.Filter + * @instance + */ + Object.defineProperty(Filter.prototype, "filterType", { + get: $util.oneOfGetter($oneOfFields = ["compositeFilter", "propertyFilter"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Filter instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Filter + * @static + * @param {google.datastore.v1.IFilter=} [properties] Properties to set + * @returns {google.datastore.v1.Filter} Filter instance + */ + Filter.create = function create(properties) { + return new Filter(properties); + }; + + /** + * Encodes the specified Filter message. Does not implicitly {@link google.datastore.v1.Filter.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Filter + * @static + * @param {google.datastore.v1.IFilter} message Filter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Filter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.compositeFilter != null && Object.hasOwnProperty.call(message, "compositeFilter")) + $root.google.datastore.v1.CompositeFilter.encode(message.compositeFilter, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.propertyFilter != null && Object.hasOwnProperty.call(message, "propertyFilter")) + $root.google.datastore.v1.PropertyFilter.encode(message.propertyFilter, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Filter message, length delimited. Does not implicitly {@link google.datastore.v1.Filter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Filter + * @static + * @param {google.datastore.v1.IFilter} message Filter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Filter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Filter message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Filter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Filter} Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Filter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Filter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.compositeFilter = $root.google.datastore.v1.CompositeFilter.decode(reader, reader.uint32()); + break; + } + case 2: { + message.propertyFilter = $root.google.datastore.v1.PropertyFilter.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Filter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Filter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Filter} Filter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Filter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Filter message. + * @function verify + * @memberof google.datastore.v1.Filter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Filter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.compositeFilter != null && message.hasOwnProperty("compositeFilter")) { + properties.filterType = 1; + { + var error = $root.google.datastore.v1.CompositeFilter.verify(message.compositeFilter); + if (error) + return "compositeFilter." + error; + } + } + if (message.propertyFilter != null && message.hasOwnProperty("propertyFilter")) { + if (properties.filterType === 1) + return "filterType: multiple values"; + properties.filterType = 1; + { + var error = $root.google.datastore.v1.PropertyFilter.verify(message.propertyFilter); + if (error) + return "propertyFilter." + error; + } + } + return null; + }; + + /** + * Creates a Filter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Filter + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Filter} Filter + */ + Filter.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Filter) + return object; + var message = new $root.google.datastore.v1.Filter(); + if (object.compositeFilter != null) { + if (typeof object.compositeFilter !== "object") + throw TypeError(".google.datastore.v1.Filter.compositeFilter: object expected"); + message.compositeFilter = $root.google.datastore.v1.CompositeFilter.fromObject(object.compositeFilter); + } + if (object.propertyFilter != null) { + if (typeof object.propertyFilter !== "object") + throw TypeError(".google.datastore.v1.Filter.propertyFilter: object expected"); + message.propertyFilter = $root.google.datastore.v1.PropertyFilter.fromObject(object.propertyFilter); + } + return message; + }; + + /** + * Creates a plain object from a Filter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Filter + * @static + * @param {google.datastore.v1.Filter} message Filter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Filter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.compositeFilter != null && message.hasOwnProperty("compositeFilter")) { + object.compositeFilter = $root.google.datastore.v1.CompositeFilter.toObject(message.compositeFilter, options); + if (options.oneofs) + object.filterType = "compositeFilter"; + } + if (message.propertyFilter != null && message.hasOwnProperty("propertyFilter")) { + object.propertyFilter = $root.google.datastore.v1.PropertyFilter.toObject(message.propertyFilter, options); + if (options.oneofs) + object.filterType = "propertyFilter"; + } + return object; + }; + + /** + * Converts this Filter to JSON. + * @function toJSON + * @memberof google.datastore.v1.Filter + * @instance + * @returns {Object.} JSON object + */ + Filter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Filter + * @function getTypeUrl + * @memberof google.datastore.v1.Filter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Filter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Filter"; + }; + + return Filter; + })(); + + v1.CompositeFilter = (function() { + + /** + * Properties of a CompositeFilter. + * @memberof google.datastore.v1 + * @interface ICompositeFilter + * @property {google.datastore.v1.CompositeFilter.Operator|null} [op] CompositeFilter op + * @property {Array.|null} [filters] CompositeFilter filters + */ + + /** + * Constructs a new CompositeFilter. + * @memberof google.datastore.v1 + * @classdesc Represents a CompositeFilter. + * @implements ICompositeFilter + * @constructor + * @param {google.datastore.v1.ICompositeFilter=} [properties] Properties to set + */ + function CompositeFilter(properties) { + this.filters = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CompositeFilter op. + * @member {google.datastore.v1.CompositeFilter.Operator} op + * @memberof google.datastore.v1.CompositeFilter + * @instance + */ + CompositeFilter.prototype.op = 0; + + /** + * CompositeFilter filters. + * @member {Array.} filters + * @memberof google.datastore.v1.CompositeFilter + * @instance + */ + CompositeFilter.prototype.filters = $util.emptyArray; + + /** + * Creates a new CompositeFilter instance using the specified properties. + * @function create + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {google.datastore.v1.ICompositeFilter=} [properties] Properties to set + * @returns {google.datastore.v1.CompositeFilter} CompositeFilter instance + */ + CompositeFilter.create = function create(properties) { + return new CompositeFilter(properties); + }; + + /** + * Encodes the specified CompositeFilter message. Does not implicitly {@link google.datastore.v1.CompositeFilter.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {google.datastore.v1.ICompositeFilter} message CompositeFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompositeFilter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.op != null && Object.hasOwnProperty.call(message, "op")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.op); + if (message.filters != null && message.filters.length) + for (var i = 0; i < message.filters.length; ++i) + $root.google.datastore.v1.Filter.encode(message.filters[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CompositeFilter message, length delimited. Does not implicitly {@link google.datastore.v1.CompositeFilter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {google.datastore.v1.ICompositeFilter} message CompositeFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CompositeFilter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.CompositeFilter} CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompositeFilter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.CompositeFilter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.op = reader.int32(); + break; + } + case 2: { + if (!(message.filters && message.filters.length)) + message.filters = []; + message.filters.push($root.google.datastore.v1.Filter.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CompositeFilter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.CompositeFilter} CompositeFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CompositeFilter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CompositeFilter message. + * @function verify + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CompositeFilter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.op != null && message.hasOwnProperty("op")) + switch (message.op) { + default: + return "op: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.filters != null && message.hasOwnProperty("filters")) { + if (!Array.isArray(message.filters)) + return "filters: array expected"; + for (var i = 0; i < message.filters.length; ++i) { + var error = $root.google.datastore.v1.Filter.verify(message.filters[i]); + if (error) + return "filters." + error; + } + } + return null; + }; + + /** + * Creates a CompositeFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.CompositeFilter} CompositeFilter + */ + CompositeFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.CompositeFilter) + return object; + var message = new $root.google.datastore.v1.CompositeFilter(); + switch (object.op) { + default: + if (typeof object.op === "number") { + message.op = object.op; + break; + } + break; + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "AND": + case 1: + message.op = 1; + break; + case "OR": + case 2: + message.op = 2; + break; + } + if (object.filters) { + if (!Array.isArray(object.filters)) + throw TypeError(".google.datastore.v1.CompositeFilter.filters: array expected"); + message.filters = []; + for (var i = 0; i < object.filters.length; ++i) { + if (typeof object.filters[i] !== "object") + throw TypeError(".google.datastore.v1.CompositeFilter.filters: object expected"); + message.filters[i] = $root.google.datastore.v1.Filter.fromObject(object.filters[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CompositeFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {google.datastore.v1.CompositeFilter} message CompositeFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CompositeFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.filters = []; + if (options.defaults) + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.datastore.v1.CompositeFilter.Operator[message.op] === undefined ? message.op : $root.google.datastore.v1.CompositeFilter.Operator[message.op] : message.op; + if (message.filters && message.filters.length) { + object.filters = []; + for (var j = 0; j < message.filters.length; ++j) + object.filters[j] = $root.google.datastore.v1.Filter.toObject(message.filters[j], options); + } + return object; + }; + + /** + * Converts this CompositeFilter to JSON. + * @function toJSON + * @memberof google.datastore.v1.CompositeFilter + * @instance + * @returns {Object.} JSON object + */ + CompositeFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CompositeFilter + * @function getTypeUrl + * @memberof google.datastore.v1.CompositeFilter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CompositeFilter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.CompositeFilter"; + }; + + /** + * Operator enum. + * @name google.datastore.v1.CompositeFilter.Operator + * @enum {number} + * @property {number} OPERATOR_UNSPECIFIED=0 OPERATOR_UNSPECIFIED value + * @property {number} AND=1 AND value + * @property {number} OR=2 OR value + */ + CompositeFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = 0; + values[valuesById[1] = "AND"] = 1; + values[valuesById[2] = "OR"] = 2; + return values; + })(); + + return CompositeFilter; + })(); + + v1.PropertyFilter = (function() { + + /** + * Properties of a PropertyFilter. + * @memberof google.datastore.v1 + * @interface IPropertyFilter + * @property {google.datastore.v1.IPropertyReference|null} [property] PropertyFilter property + * @property {google.datastore.v1.PropertyFilter.Operator|null} [op] PropertyFilter op + * @property {google.datastore.v1.IValue|null} [value] PropertyFilter value + */ + + /** + * Constructs a new PropertyFilter. + * @memberof google.datastore.v1 + * @classdesc Represents a PropertyFilter. + * @implements IPropertyFilter + * @constructor + * @param {google.datastore.v1.IPropertyFilter=} [properties] Properties to set + */ + function PropertyFilter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PropertyFilter property. + * @member {google.datastore.v1.IPropertyReference|null|undefined} property + * @memberof google.datastore.v1.PropertyFilter + * @instance + */ + PropertyFilter.prototype.property = null; + + /** + * PropertyFilter op. + * @member {google.datastore.v1.PropertyFilter.Operator} op + * @memberof google.datastore.v1.PropertyFilter + * @instance + */ + PropertyFilter.prototype.op = 0; + + /** + * PropertyFilter value. + * @member {google.datastore.v1.IValue|null|undefined} value + * @memberof google.datastore.v1.PropertyFilter + * @instance + */ + PropertyFilter.prototype.value = null; + + /** + * Creates a new PropertyFilter instance using the specified properties. + * @function create + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {google.datastore.v1.IPropertyFilter=} [properties] Properties to set + * @returns {google.datastore.v1.PropertyFilter} PropertyFilter instance + */ + PropertyFilter.create = function create(properties) { + return new PropertyFilter(properties); + }; + + /** + * Encodes the specified PropertyFilter message. Does not implicitly {@link google.datastore.v1.PropertyFilter.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {google.datastore.v1.IPropertyFilter} message PropertyFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyFilter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.property != null && Object.hasOwnProperty.call(message, "property")) + $root.google.datastore.v1.PropertyReference.encode(message.property, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.op != null && Object.hasOwnProperty.call(message, "op")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.op); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + $root.google.datastore.v1.Value.encode(message.value, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PropertyFilter message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyFilter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {google.datastore.v1.IPropertyFilter} message PropertyFilter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyFilter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PropertyFilter message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.PropertyFilter} PropertyFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyFilter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.PropertyFilter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.property = $root.google.datastore.v1.PropertyReference.decode(reader, reader.uint32()); + break; + } + case 2: { + message.op = reader.int32(); + break; + } + case 3: { + message.value = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PropertyFilter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.PropertyFilter} PropertyFilter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyFilter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PropertyFilter message. + * @function verify + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PropertyFilter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.property != null && message.hasOwnProperty("property")) { + var error = $root.google.datastore.v1.PropertyReference.verify(message.property); + if (error) + return "property." + error; + } + if (message.op != null && message.hasOwnProperty("op")) + switch (message.op) { + default: + return "op: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 9: + case 11: + case 13: + break; + } + if (message.value != null && message.hasOwnProperty("value")) { + var error = $root.google.datastore.v1.Value.verify(message.value); + if (error) + return "value." + error; + } + return null; + }; + + /** + * Creates a PropertyFilter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.PropertyFilter} PropertyFilter + */ + PropertyFilter.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.PropertyFilter) + return object; + var message = new $root.google.datastore.v1.PropertyFilter(); + if (object.property != null) { + if (typeof object.property !== "object") + throw TypeError(".google.datastore.v1.PropertyFilter.property: object expected"); + message.property = $root.google.datastore.v1.PropertyReference.fromObject(object.property); + } + switch (object.op) { + default: + if (typeof object.op === "number") { + message.op = object.op; + break; + } + break; + case "OPERATOR_UNSPECIFIED": + case 0: + message.op = 0; + break; + case "LESS_THAN": + case 1: + message.op = 1; + break; + case "LESS_THAN_OR_EQUAL": + case 2: + message.op = 2; + break; + case "GREATER_THAN": + case 3: + message.op = 3; + break; + case "GREATER_THAN_OR_EQUAL": + case 4: + message.op = 4; + break; + case "EQUAL": + case 5: + message.op = 5; + break; + case "IN": + case 6: + message.op = 6; + break; + case "NOT_EQUAL": + case 9: + message.op = 9; + break; + case "HAS_ANCESTOR": + case 11: + message.op = 11; + break; + case "NOT_IN": + case 13: + message.op = 13; + break; + } + if (object.value != null) { + if (typeof object.value !== "object") + throw TypeError(".google.datastore.v1.PropertyFilter.value: object expected"); + message.value = $root.google.datastore.v1.Value.fromObject(object.value); + } + return message; + }; + + /** + * Creates a plain object from a PropertyFilter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {google.datastore.v1.PropertyFilter} message PropertyFilter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PropertyFilter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.property = null; + object.op = options.enums === String ? "OPERATOR_UNSPECIFIED" : 0; + object.value = null; + } + if (message.property != null && message.hasOwnProperty("property")) + object.property = $root.google.datastore.v1.PropertyReference.toObject(message.property, options); + if (message.op != null && message.hasOwnProperty("op")) + object.op = options.enums === String ? $root.google.datastore.v1.PropertyFilter.Operator[message.op] === undefined ? message.op : $root.google.datastore.v1.PropertyFilter.Operator[message.op] : message.op; + if (message.value != null && message.hasOwnProperty("value")) + object.value = $root.google.datastore.v1.Value.toObject(message.value, options); + return object; + }; + + /** + * Converts this PropertyFilter to JSON. + * @function toJSON + * @memberof google.datastore.v1.PropertyFilter + * @instance + * @returns {Object.} JSON object + */ + PropertyFilter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PropertyFilter + * @function getTypeUrl + * @memberof google.datastore.v1.PropertyFilter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PropertyFilter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.PropertyFilter"; + }; + + /** + * Operator enum. + * @name google.datastore.v1.PropertyFilter.Operator + * @enum {number} + * @property {number} OPERATOR_UNSPECIFIED=0 OPERATOR_UNSPECIFIED value + * @property {number} LESS_THAN=1 LESS_THAN value + * @property {number} LESS_THAN_OR_EQUAL=2 LESS_THAN_OR_EQUAL value + * @property {number} GREATER_THAN=3 GREATER_THAN value + * @property {number} GREATER_THAN_OR_EQUAL=4 GREATER_THAN_OR_EQUAL value + * @property {number} EQUAL=5 EQUAL value + * @property {number} IN=6 IN value + * @property {number} NOT_EQUAL=9 NOT_EQUAL value + * @property {number} HAS_ANCESTOR=11 HAS_ANCESTOR value + * @property {number} NOT_IN=13 NOT_IN value + */ + PropertyFilter.Operator = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "OPERATOR_UNSPECIFIED"] = 0; + values[valuesById[1] = "LESS_THAN"] = 1; + values[valuesById[2] = "LESS_THAN_OR_EQUAL"] = 2; + values[valuesById[3] = "GREATER_THAN"] = 3; + values[valuesById[4] = "GREATER_THAN_OR_EQUAL"] = 4; + values[valuesById[5] = "EQUAL"] = 5; + values[valuesById[6] = "IN"] = 6; + values[valuesById[9] = "NOT_EQUAL"] = 9; + values[valuesById[11] = "HAS_ANCESTOR"] = 11; + values[valuesById[13] = "NOT_IN"] = 13; + return values; + })(); + + return PropertyFilter; + })(); + + v1.FindNearest = (function() { + + /** + * Properties of a FindNearest. + * @memberof google.datastore.v1 + * @interface IFindNearest + * @property {google.datastore.v1.IPropertyReference|null} [vectorProperty] FindNearest vectorProperty + * @property {google.datastore.v1.IValue|null} [queryVector] FindNearest queryVector + * @property {google.datastore.v1.FindNearest.DistanceMeasure|null} [distanceMeasure] FindNearest distanceMeasure + * @property {google.protobuf.IInt32Value|null} [limit] FindNearest limit + * @property {string|null} [distanceResultProperty] FindNearest distanceResultProperty + * @property {google.protobuf.IDoubleValue|null} [distanceThreshold] FindNearest distanceThreshold + */ + + /** + * Constructs a new FindNearest. + * @memberof google.datastore.v1 + * @classdesc Represents a FindNearest. + * @implements IFindNearest + * @constructor + * @param {google.datastore.v1.IFindNearest=} [properties] Properties to set + */ + function FindNearest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FindNearest vectorProperty. + * @member {google.datastore.v1.IPropertyReference|null|undefined} vectorProperty + * @memberof google.datastore.v1.FindNearest + * @instance + */ + FindNearest.prototype.vectorProperty = null; + + /** + * FindNearest queryVector. + * @member {google.datastore.v1.IValue|null|undefined} queryVector + * @memberof google.datastore.v1.FindNearest + * @instance + */ + FindNearest.prototype.queryVector = null; + + /** + * FindNearest distanceMeasure. + * @member {google.datastore.v1.FindNearest.DistanceMeasure} distanceMeasure + * @memberof google.datastore.v1.FindNearest + * @instance + */ + FindNearest.prototype.distanceMeasure = 0; + + /** + * FindNearest limit. + * @member {google.protobuf.IInt32Value|null|undefined} limit + * @memberof google.datastore.v1.FindNearest + * @instance + */ + FindNearest.prototype.limit = null; + + /** + * FindNearest distanceResultProperty. + * @member {string} distanceResultProperty + * @memberof google.datastore.v1.FindNearest + * @instance + */ + FindNearest.prototype.distanceResultProperty = ""; + + /** + * FindNearest distanceThreshold. + * @member {google.protobuf.IDoubleValue|null|undefined} distanceThreshold + * @memberof google.datastore.v1.FindNearest + * @instance + */ + FindNearest.prototype.distanceThreshold = null; + + /** + * Creates a new FindNearest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.FindNearest + * @static + * @param {google.datastore.v1.IFindNearest=} [properties] Properties to set + * @returns {google.datastore.v1.FindNearest} FindNearest instance + */ + FindNearest.create = function create(properties) { + return new FindNearest(properties); + }; + + /** + * Encodes the specified FindNearest message. Does not implicitly {@link google.datastore.v1.FindNearest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.FindNearest + * @static + * @param {google.datastore.v1.IFindNearest} message FindNearest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FindNearest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.vectorProperty != null && Object.hasOwnProperty.call(message, "vectorProperty")) + $root.google.datastore.v1.PropertyReference.encode(message.vectorProperty, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.queryVector != null && Object.hasOwnProperty.call(message, "queryVector")) + $root.google.datastore.v1.Value.encode(message.queryVector, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.distanceMeasure != null && Object.hasOwnProperty.call(message, "distanceMeasure")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.distanceMeasure); + if (message.limit != null && Object.hasOwnProperty.call(message, "limit")) + $root.google.protobuf.Int32Value.encode(message.limit, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.distanceResultProperty != null && Object.hasOwnProperty.call(message, "distanceResultProperty")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.distanceResultProperty); + if (message.distanceThreshold != null && Object.hasOwnProperty.call(message, "distanceThreshold")) + $root.google.protobuf.DoubleValue.encode(message.distanceThreshold, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FindNearest message, length delimited. Does not implicitly {@link google.datastore.v1.FindNearest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.FindNearest + * @static + * @param {google.datastore.v1.IFindNearest} message FindNearest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FindNearest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FindNearest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.FindNearest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.FindNearest} FindNearest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FindNearest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.FindNearest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.vectorProperty = $root.google.datastore.v1.PropertyReference.decode(reader, reader.uint32()); + break; + } + case 2: { + message.queryVector = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + } + case 3: { + message.distanceMeasure = reader.int32(); + break; + } + case 4: { + message.limit = $root.google.protobuf.Int32Value.decode(reader, reader.uint32()); + break; + } + case 5: { + message.distanceResultProperty = reader.string(); + break; + } + case 6: { + message.distanceThreshold = $root.google.protobuf.DoubleValue.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FindNearest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.FindNearest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.FindNearest} FindNearest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FindNearest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FindNearest message. + * @function verify + * @memberof google.datastore.v1.FindNearest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FindNearest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.vectorProperty != null && message.hasOwnProperty("vectorProperty")) { + var error = $root.google.datastore.v1.PropertyReference.verify(message.vectorProperty); + if (error) + return "vectorProperty." + error; + } + if (message.queryVector != null && message.hasOwnProperty("queryVector")) { + var error = $root.google.datastore.v1.Value.verify(message.queryVector); + if (error) + return "queryVector." + error; + } + if (message.distanceMeasure != null && message.hasOwnProperty("distanceMeasure")) + switch (message.distanceMeasure) { + default: + return "distanceMeasure: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.limit != null && message.hasOwnProperty("limit")) { + var error = $root.google.protobuf.Int32Value.verify(message.limit); + if (error) + return "limit." + error; + } + if (message.distanceResultProperty != null && message.hasOwnProperty("distanceResultProperty")) + if (!$util.isString(message.distanceResultProperty)) + return "distanceResultProperty: string expected"; + if (message.distanceThreshold != null && message.hasOwnProperty("distanceThreshold")) { + var error = $root.google.protobuf.DoubleValue.verify(message.distanceThreshold); + if (error) + return "distanceThreshold." + error; + } + return null; + }; + + /** + * Creates a FindNearest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.FindNearest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.FindNearest} FindNearest + */ + FindNearest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.FindNearest) + return object; + var message = new $root.google.datastore.v1.FindNearest(); + if (object.vectorProperty != null) { + if (typeof object.vectorProperty !== "object") + throw TypeError(".google.datastore.v1.FindNearest.vectorProperty: object expected"); + message.vectorProperty = $root.google.datastore.v1.PropertyReference.fromObject(object.vectorProperty); + } + if (object.queryVector != null) { + if (typeof object.queryVector !== "object") + throw TypeError(".google.datastore.v1.FindNearest.queryVector: object expected"); + message.queryVector = $root.google.datastore.v1.Value.fromObject(object.queryVector); + } + switch (object.distanceMeasure) { + default: + if (typeof object.distanceMeasure === "number") { + message.distanceMeasure = object.distanceMeasure; + break; + } + break; + case "DISTANCE_MEASURE_UNSPECIFIED": + case 0: + message.distanceMeasure = 0; + break; + case "EUCLIDEAN": + case 1: + message.distanceMeasure = 1; + break; + case "COSINE": + case 2: + message.distanceMeasure = 2; + break; + case "DOT_PRODUCT": + case 3: + message.distanceMeasure = 3; + break; + } + if (object.limit != null) { + if (typeof object.limit !== "object") + throw TypeError(".google.datastore.v1.FindNearest.limit: object expected"); + message.limit = $root.google.protobuf.Int32Value.fromObject(object.limit); + } + if (object.distanceResultProperty != null) + message.distanceResultProperty = String(object.distanceResultProperty); + if (object.distanceThreshold != null) { + if (typeof object.distanceThreshold !== "object") + throw TypeError(".google.datastore.v1.FindNearest.distanceThreshold: object expected"); + message.distanceThreshold = $root.google.protobuf.DoubleValue.fromObject(object.distanceThreshold); + } + return message; + }; + + /** + * Creates a plain object from a FindNearest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.FindNearest + * @static + * @param {google.datastore.v1.FindNearest} message FindNearest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FindNearest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.vectorProperty = null; + object.queryVector = null; + object.distanceMeasure = options.enums === String ? "DISTANCE_MEASURE_UNSPECIFIED" : 0; + object.limit = null; + object.distanceResultProperty = ""; + object.distanceThreshold = null; + } + if (message.vectorProperty != null && message.hasOwnProperty("vectorProperty")) + object.vectorProperty = $root.google.datastore.v1.PropertyReference.toObject(message.vectorProperty, options); + if (message.queryVector != null && message.hasOwnProperty("queryVector")) + object.queryVector = $root.google.datastore.v1.Value.toObject(message.queryVector, options); + if (message.distanceMeasure != null && message.hasOwnProperty("distanceMeasure")) + object.distanceMeasure = options.enums === String ? $root.google.datastore.v1.FindNearest.DistanceMeasure[message.distanceMeasure] === undefined ? message.distanceMeasure : $root.google.datastore.v1.FindNearest.DistanceMeasure[message.distanceMeasure] : message.distanceMeasure; + if (message.limit != null && message.hasOwnProperty("limit")) + object.limit = $root.google.protobuf.Int32Value.toObject(message.limit, options); + if (message.distanceResultProperty != null && message.hasOwnProperty("distanceResultProperty")) + object.distanceResultProperty = message.distanceResultProperty; + if (message.distanceThreshold != null && message.hasOwnProperty("distanceThreshold")) + object.distanceThreshold = $root.google.protobuf.DoubleValue.toObject(message.distanceThreshold, options); + return object; + }; + + /** + * Converts this FindNearest to JSON. + * @function toJSON + * @memberof google.datastore.v1.FindNearest + * @instance + * @returns {Object.} JSON object + */ + FindNearest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FindNearest + * @function getTypeUrl + * @memberof google.datastore.v1.FindNearest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FindNearest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.FindNearest"; + }; + + /** + * DistanceMeasure enum. + * @name google.datastore.v1.FindNearest.DistanceMeasure + * @enum {number} + * @property {number} DISTANCE_MEASURE_UNSPECIFIED=0 DISTANCE_MEASURE_UNSPECIFIED value + * @property {number} EUCLIDEAN=1 EUCLIDEAN value + * @property {number} COSINE=2 COSINE value + * @property {number} DOT_PRODUCT=3 DOT_PRODUCT value + */ + FindNearest.DistanceMeasure = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DISTANCE_MEASURE_UNSPECIFIED"] = 0; + values[valuesById[1] = "EUCLIDEAN"] = 1; + values[valuesById[2] = "COSINE"] = 2; + values[valuesById[3] = "DOT_PRODUCT"] = 3; + return values; + })(); + + return FindNearest; + })(); + + v1.GqlQuery = (function() { + + /** + * Properties of a GqlQuery. + * @memberof google.datastore.v1 + * @interface IGqlQuery + * @property {string|null} [queryString] GqlQuery queryString + * @property {boolean|null} [allowLiterals] GqlQuery allowLiterals + * @property {Object.|null} [namedBindings] GqlQuery namedBindings + * @property {Array.|null} [positionalBindings] GqlQuery positionalBindings + */ + + /** + * Constructs a new GqlQuery. + * @memberof google.datastore.v1 + * @classdesc Represents a GqlQuery. + * @implements IGqlQuery + * @constructor + * @param {google.datastore.v1.IGqlQuery=} [properties] Properties to set + */ + function GqlQuery(properties) { + this.namedBindings = {}; + this.positionalBindings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GqlQuery queryString. + * @member {string} queryString + * @memberof google.datastore.v1.GqlQuery + * @instance + */ + GqlQuery.prototype.queryString = ""; + + /** + * GqlQuery allowLiterals. + * @member {boolean} allowLiterals + * @memberof google.datastore.v1.GqlQuery + * @instance + */ + GqlQuery.prototype.allowLiterals = false; + + /** + * GqlQuery namedBindings. + * @member {Object.} namedBindings + * @memberof google.datastore.v1.GqlQuery + * @instance + */ + GqlQuery.prototype.namedBindings = $util.emptyObject; + + /** + * GqlQuery positionalBindings. + * @member {Array.} positionalBindings + * @memberof google.datastore.v1.GqlQuery + * @instance + */ + GqlQuery.prototype.positionalBindings = $util.emptyArray; + + /** + * Creates a new GqlQuery instance using the specified properties. + * @function create + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {google.datastore.v1.IGqlQuery=} [properties] Properties to set + * @returns {google.datastore.v1.GqlQuery} GqlQuery instance + */ + GqlQuery.create = function create(properties) { + return new GqlQuery(properties); + }; + + /** + * Encodes the specified GqlQuery message. Does not implicitly {@link google.datastore.v1.GqlQuery.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {google.datastore.v1.IGqlQuery} message GqlQuery message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GqlQuery.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.queryString != null && Object.hasOwnProperty.call(message, "queryString")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.queryString); + if (message.allowLiterals != null && Object.hasOwnProperty.call(message, "allowLiterals")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowLiterals); + if (message.positionalBindings != null && message.positionalBindings.length) + for (var i = 0; i < message.positionalBindings.length; ++i) + $root.google.datastore.v1.GqlQueryParameter.encode(message.positionalBindings[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.namedBindings != null && Object.hasOwnProperty.call(message, "namedBindings")) + for (var keys = Object.keys(message.namedBindings), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 5, wireType 2 =*/42).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.datastore.v1.GqlQueryParameter.encode(message.namedBindings[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified GqlQuery message, length delimited. Does not implicitly {@link google.datastore.v1.GqlQuery.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {google.datastore.v1.IGqlQuery} message GqlQuery message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GqlQuery.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GqlQuery message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.GqlQuery} GqlQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GqlQuery.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.GqlQuery(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.queryString = reader.string(); + break; + } + case 2: { + message.allowLiterals = reader.bool(); + break; + } + case 5: { + if (message.namedBindings === $util.emptyObject) + message.namedBindings = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.google.datastore.v1.GqlQueryParameter.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.namedBindings[key] = value; + break; + } + case 4: { + if (!(message.positionalBindings && message.positionalBindings.length)) + message.positionalBindings = []; + message.positionalBindings.push($root.google.datastore.v1.GqlQueryParameter.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GqlQuery message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.GqlQuery} GqlQuery + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GqlQuery.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GqlQuery message. + * @function verify + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GqlQuery.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.queryString != null && message.hasOwnProperty("queryString")) + if (!$util.isString(message.queryString)) + return "queryString: string expected"; + if (message.allowLiterals != null && message.hasOwnProperty("allowLiterals")) + if (typeof message.allowLiterals !== "boolean") + return "allowLiterals: boolean expected"; + if (message.namedBindings != null && message.hasOwnProperty("namedBindings")) { + if (!$util.isObject(message.namedBindings)) + return "namedBindings: object expected"; + var key = Object.keys(message.namedBindings); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.datastore.v1.GqlQueryParameter.verify(message.namedBindings[key[i]]); + if (error) + return "namedBindings." + error; + } + } + if (message.positionalBindings != null && message.hasOwnProperty("positionalBindings")) { + if (!Array.isArray(message.positionalBindings)) + return "positionalBindings: array expected"; + for (var i = 0; i < message.positionalBindings.length; ++i) { + var error = $root.google.datastore.v1.GqlQueryParameter.verify(message.positionalBindings[i]); + if (error) + return "positionalBindings." + error; + } + } + return null; + }; + + /** + * Creates a GqlQuery message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.GqlQuery} GqlQuery + */ + GqlQuery.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.GqlQuery) + return object; + var message = new $root.google.datastore.v1.GqlQuery(); + if (object.queryString != null) + message.queryString = String(object.queryString); + if (object.allowLiterals != null) + message.allowLiterals = Boolean(object.allowLiterals); + if (object.namedBindings) { + if (typeof object.namedBindings !== "object") + throw TypeError(".google.datastore.v1.GqlQuery.namedBindings: object expected"); + message.namedBindings = {}; + for (var keys = Object.keys(object.namedBindings), i = 0; i < keys.length; ++i) { + if (typeof object.namedBindings[keys[i]] !== "object") + throw TypeError(".google.datastore.v1.GqlQuery.namedBindings: object expected"); + message.namedBindings[keys[i]] = $root.google.datastore.v1.GqlQueryParameter.fromObject(object.namedBindings[keys[i]]); + } + } + if (object.positionalBindings) { + if (!Array.isArray(object.positionalBindings)) + throw TypeError(".google.datastore.v1.GqlQuery.positionalBindings: array expected"); + message.positionalBindings = []; + for (var i = 0; i < object.positionalBindings.length; ++i) { + if (typeof object.positionalBindings[i] !== "object") + throw TypeError(".google.datastore.v1.GqlQuery.positionalBindings: object expected"); + message.positionalBindings[i] = $root.google.datastore.v1.GqlQueryParameter.fromObject(object.positionalBindings[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a GqlQuery message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {google.datastore.v1.GqlQuery} message GqlQuery + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GqlQuery.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.positionalBindings = []; + if (options.objects || options.defaults) + object.namedBindings = {}; + if (options.defaults) { + object.queryString = ""; + object.allowLiterals = false; + } + if (message.queryString != null && message.hasOwnProperty("queryString")) + object.queryString = message.queryString; + if (message.allowLiterals != null && message.hasOwnProperty("allowLiterals")) + object.allowLiterals = message.allowLiterals; + if (message.positionalBindings && message.positionalBindings.length) { + object.positionalBindings = []; + for (var j = 0; j < message.positionalBindings.length; ++j) + object.positionalBindings[j] = $root.google.datastore.v1.GqlQueryParameter.toObject(message.positionalBindings[j], options); + } + var keys2; + if (message.namedBindings && (keys2 = Object.keys(message.namedBindings)).length) { + object.namedBindings = {}; + for (var j = 0; j < keys2.length; ++j) + object.namedBindings[keys2[j]] = $root.google.datastore.v1.GqlQueryParameter.toObject(message.namedBindings[keys2[j]], options); + } + return object; + }; + + /** + * Converts this GqlQuery to JSON. + * @function toJSON + * @memberof google.datastore.v1.GqlQuery + * @instance + * @returns {Object.} JSON object + */ + GqlQuery.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GqlQuery + * @function getTypeUrl + * @memberof google.datastore.v1.GqlQuery + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GqlQuery.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.GqlQuery"; + }; + + return GqlQuery; + })(); + + v1.GqlQueryParameter = (function() { + + /** + * Properties of a GqlQueryParameter. + * @memberof google.datastore.v1 + * @interface IGqlQueryParameter + * @property {google.datastore.v1.IValue|null} [value] GqlQueryParameter value + * @property {Uint8Array|null} [cursor] GqlQueryParameter cursor + */ + + /** + * Constructs a new GqlQueryParameter. + * @memberof google.datastore.v1 + * @classdesc Represents a GqlQueryParameter. + * @implements IGqlQueryParameter + * @constructor + * @param {google.datastore.v1.IGqlQueryParameter=} [properties] Properties to set + */ + function GqlQueryParameter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GqlQueryParameter value. + * @member {google.datastore.v1.IValue|null|undefined} value + * @memberof google.datastore.v1.GqlQueryParameter + * @instance + */ + GqlQueryParameter.prototype.value = null; + + /** + * GqlQueryParameter cursor. + * @member {Uint8Array|null|undefined} cursor + * @memberof google.datastore.v1.GqlQueryParameter + * @instance + */ + GqlQueryParameter.prototype.cursor = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * GqlQueryParameter parameterType. + * @member {"value"|"cursor"|undefined} parameterType + * @memberof google.datastore.v1.GqlQueryParameter + * @instance + */ + Object.defineProperty(GqlQueryParameter.prototype, "parameterType", { + get: $util.oneOfGetter($oneOfFields = ["value", "cursor"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new GqlQueryParameter instance using the specified properties. + * @function create + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {google.datastore.v1.IGqlQueryParameter=} [properties] Properties to set + * @returns {google.datastore.v1.GqlQueryParameter} GqlQueryParameter instance + */ + GqlQueryParameter.create = function create(properties) { + return new GqlQueryParameter(properties); + }; + + /** + * Encodes the specified GqlQueryParameter message. Does not implicitly {@link google.datastore.v1.GqlQueryParameter.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {google.datastore.v1.IGqlQueryParameter} message GqlQueryParameter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GqlQueryParameter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + $root.google.datastore.v1.Value.encode(message.value, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.cursor != null && Object.hasOwnProperty.call(message, "cursor")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.cursor); + return writer; + }; + + /** + * Encodes the specified GqlQueryParameter message, length delimited. Does not implicitly {@link google.datastore.v1.GqlQueryParameter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {google.datastore.v1.IGqlQueryParameter} message GqlQueryParameter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GqlQueryParameter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GqlQueryParameter message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.GqlQueryParameter} GqlQueryParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GqlQueryParameter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.GqlQueryParameter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.value = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + } + case 3: { + message.cursor = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GqlQueryParameter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.GqlQueryParameter} GqlQueryParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GqlQueryParameter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GqlQueryParameter message. + * @function verify + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GqlQueryParameter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.value != null && message.hasOwnProperty("value")) { + properties.parameterType = 1; + { + var error = $root.google.datastore.v1.Value.verify(message.value); + if (error) + return "value." + error; + } + } + if (message.cursor != null && message.hasOwnProperty("cursor")) { + if (properties.parameterType === 1) + return "parameterType: multiple values"; + properties.parameterType = 1; + if (!(message.cursor && typeof message.cursor.length === "number" || $util.isString(message.cursor))) + return "cursor: buffer expected"; + } + return null; + }; + + /** + * Creates a GqlQueryParameter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.GqlQueryParameter} GqlQueryParameter + */ + GqlQueryParameter.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.GqlQueryParameter) + return object; + var message = new $root.google.datastore.v1.GqlQueryParameter(); + if (object.value != null) { + if (typeof object.value !== "object") + throw TypeError(".google.datastore.v1.GqlQueryParameter.value: object expected"); + message.value = $root.google.datastore.v1.Value.fromObject(object.value); + } + if (object.cursor != null) + if (typeof object.cursor === "string") + $util.base64.decode(object.cursor, message.cursor = $util.newBuffer($util.base64.length(object.cursor)), 0); + else if (object.cursor.length >= 0) + message.cursor = object.cursor; + return message; + }; + + /** + * Creates a plain object from a GqlQueryParameter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {google.datastore.v1.GqlQueryParameter} message GqlQueryParameter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GqlQueryParameter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.value != null && message.hasOwnProperty("value")) { + object.value = $root.google.datastore.v1.Value.toObject(message.value, options); + if (options.oneofs) + object.parameterType = "value"; + } + if (message.cursor != null && message.hasOwnProperty("cursor")) { + object.cursor = options.bytes === String ? $util.base64.encode(message.cursor, 0, message.cursor.length) : options.bytes === Array ? Array.prototype.slice.call(message.cursor) : message.cursor; + if (options.oneofs) + object.parameterType = "cursor"; + } + return object; + }; + + /** + * Converts this GqlQueryParameter to JSON. + * @function toJSON + * @memberof google.datastore.v1.GqlQueryParameter + * @instance + * @returns {Object.} JSON object + */ + GqlQueryParameter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GqlQueryParameter + * @function getTypeUrl + * @memberof google.datastore.v1.GqlQueryParameter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GqlQueryParameter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.GqlQueryParameter"; + }; + + return GqlQueryParameter; + })(); + + v1.QueryResultBatch = (function() { + + /** + * Properties of a QueryResultBatch. + * @memberof google.datastore.v1 + * @interface IQueryResultBatch + * @property {number|null} [skippedResults] QueryResultBatch skippedResults + * @property {Uint8Array|null} [skippedCursor] QueryResultBatch skippedCursor + * @property {google.datastore.v1.EntityResult.ResultType|null} [entityResultType] QueryResultBatch entityResultType + * @property {Array.|null} [entityResults] QueryResultBatch entityResults + * @property {Uint8Array|null} [endCursor] QueryResultBatch endCursor + * @property {google.datastore.v1.QueryResultBatch.MoreResultsType|null} [moreResults] QueryResultBatch moreResults + * @property {number|Long|null} [snapshotVersion] QueryResultBatch snapshotVersion + * @property {google.protobuf.ITimestamp|null} [readTime] QueryResultBatch readTime + */ + + /** + * Constructs a new QueryResultBatch. + * @memberof google.datastore.v1 + * @classdesc Represents a QueryResultBatch. + * @implements IQueryResultBatch + * @constructor + * @param {google.datastore.v1.IQueryResultBatch=} [properties] Properties to set + */ + function QueryResultBatch(properties) { + this.entityResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * QueryResultBatch skippedResults. + * @member {number} skippedResults + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.skippedResults = 0; + + /** + * QueryResultBatch skippedCursor. + * @member {Uint8Array} skippedCursor + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.skippedCursor = $util.newBuffer([]); + + /** + * QueryResultBatch entityResultType. + * @member {google.datastore.v1.EntityResult.ResultType} entityResultType + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.entityResultType = 0; + + /** + * QueryResultBatch entityResults. + * @member {Array.} entityResults + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.entityResults = $util.emptyArray; + + /** + * QueryResultBatch endCursor. + * @member {Uint8Array} endCursor + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.endCursor = $util.newBuffer([]); + + /** + * QueryResultBatch moreResults. + * @member {google.datastore.v1.QueryResultBatch.MoreResultsType} moreResults + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.moreResults = 0; + + /** + * QueryResultBatch snapshotVersion. + * @member {number|Long} snapshotVersion + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.snapshotVersion = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * QueryResultBatch readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.datastore.v1.QueryResultBatch + * @instance + */ + QueryResultBatch.prototype.readTime = null; + + /** + * Creates a new QueryResultBatch instance using the specified properties. + * @function create + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {google.datastore.v1.IQueryResultBatch=} [properties] Properties to set + * @returns {google.datastore.v1.QueryResultBatch} QueryResultBatch instance + */ + QueryResultBatch.create = function create(properties) { + return new QueryResultBatch(properties); + }; + + /** + * Encodes the specified QueryResultBatch message. Does not implicitly {@link google.datastore.v1.QueryResultBatch.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {google.datastore.v1.IQueryResultBatch} message QueryResultBatch message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryResultBatch.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.entityResultType != null && Object.hasOwnProperty.call(message, "entityResultType")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.entityResultType); + if (message.entityResults != null && message.entityResults.length) + for (var i = 0; i < message.entityResults.length; ++i) + $root.google.datastore.v1.EntityResult.encode(message.entityResults[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.skippedCursor != null && Object.hasOwnProperty.call(message, "skippedCursor")) + writer.uint32(/* id 3, wireType 2 =*/26).bytes(message.skippedCursor); + if (message.endCursor != null && Object.hasOwnProperty.call(message, "endCursor")) + writer.uint32(/* id 4, wireType 2 =*/34).bytes(message.endCursor); + if (message.moreResults != null && Object.hasOwnProperty.call(message, "moreResults")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.moreResults); + if (message.skippedResults != null && Object.hasOwnProperty.call(message, "skippedResults")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.skippedResults); + if (message.snapshotVersion != null && Object.hasOwnProperty.call(message, "snapshotVersion")) + writer.uint32(/* id 7, wireType 0 =*/56).int64(message.snapshotVersion); + if (message.readTime != null && Object.hasOwnProperty.call(message, "readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified QueryResultBatch message, length delimited. Does not implicitly {@link google.datastore.v1.QueryResultBatch.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {google.datastore.v1.IQueryResultBatch} message QueryResultBatch message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + QueryResultBatch.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a QueryResultBatch message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.QueryResultBatch} QueryResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryResultBatch.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.QueryResultBatch(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 6: { + message.skippedResults = reader.int32(); + break; + } + case 3: { + message.skippedCursor = reader.bytes(); + break; + } + case 1: { + message.entityResultType = reader.int32(); + break; + } + case 2: { + if (!(message.entityResults && message.entityResults.length)) + message.entityResults = []; + message.entityResults.push($root.google.datastore.v1.EntityResult.decode(reader, reader.uint32())); + break; + } + case 4: { + message.endCursor = reader.bytes(); + break; + } + case 5: { + message.moreResults = reader.int32(); + break; + } + case 7: { + message.snapshotVersion = reader.int64(); + break; + } + case 8: { + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a QueryResultBatch message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.QueryResultBatch} QueryResultBatch + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + QueryResultBatch.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a QueryResultBatch message. + * @function verify + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + QueryResultBatch.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.skippedResults != null && message.hasOwnProperty("skippedResults")) + if (!$util.isInteger(message.skippedResults)) + return "skippedResults: integer expected"; + if (message.skippedCursor != null && message.hasOwnProperty("skippedCursor")) + if (!(message.skippedCursor && typeof message.skippedCursor.length === "number" || $util.isString(message.skippedCursor))) + return "skippedCursor: buffer expected"; + if (message.entityResultType != null && message.hasOwnProperty("entityResultType")) + switch (message.entityResultType) { + default: + return "entityResultType: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.entityResults != null && message.hasOwnProperty("entityResults")) { + if (!Array.isArray(message.entityResults)) + return "entityResults: array expected"; + for (var i = 0; i < message.entityResults.length; ++i) { + var error = $root.google.datastore.v1.EntityResult.verify(message.entityResults[i]); + if (error) + return "entityResults." + error; + } + } + if (message.endCursor != null && message.hasOwnProperty("endCursor")) + if (!(message.endCursor && typeof message.endCursor.length === "number" || $util.isString(message.endCursor))) + return "endCursor: buffer expected"; + if (message.moreResults != null && message.hasOwnProperty("moreResults")) + switch (message.moreResults) { + default: + return "moreResults: enum value expected"; + case 0: + case 1: + case 2: + case 4: + case 3: + break; + } + if (message.snapshotVersion != null && message.hasOwnProperty("snapshotVersion")) + if (!$util.isInteger(message.snapshotVersion) && !(message.snapshotVersion && $util.isInteger(message.snapshotVersion.low) && $util.isInteger(message.snapshotVersion.high))) + return "snapshotVersion: integer|Long expected"; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return null; + }; + + /** + * Creates a QueryResultBatch message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.QueryResultBatch} QueryResultBatch + */ + QueryResultBatch.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.QueryResultBatch) + return object; + var message = new $root.google.datastore.v1.QueryResultBatch(); + if (object.skippedResults != null) + message.skippedResults = object.skippedResults | 0; + if (object.skippedCursor != null) + if (typeof object.skippedCursor === "string") + $util.base64.decode(object.skippedCursor, message.skippedCursor = $util.newBuffer($util.base64.length(object.skippedCursor)), 0); + else if (object.skippedCursor.length >= 0) + message.skippedCursor = object.skippedCursor; + switch (object.entityResultType) { + default: + if (typeof object.entityResultType === "number") { + message.entityResultType = object.entityResultType; + break; + } + break; + case "RESULT_TYPE_UNSPECIFIED": + case 0: + message.entityResultType = 0; + break; + case "FULL": + case 1: + message.entityResultType = 1; + break; + case "PROJECTION": + case 2: + message.entityResultType = 2; + break; + case "KEY_ONLY": + case 3: + message.entityResultType = 3; + break; + } + if (object.entityResults) { + if (!Array.isArray(object.entityResults)) + throw TypeError(".google.datastore.v1.QueryResultBatch.entityResults: array expected"); + message.entityResults = []; + for (var i = 0; i < object.entityResults.length; ++i) { + if (typeof object.entityResults[i] !== "object") + throw TypeError(".google.datastore.v1.QueryResultBatch.entityResults: object expected"); + message.entityResults[i] = $root.google.datastore.v1.EntityResult.fromObject(object.entityResults[i]); + } + } + if (object.endCursor != null) + if (typeof object.endCursor === "string") + $util.base64.decode(object.endCursor, message.endCursor = $util.newBuffer($util.base64.length(object.endCursor)), 0); + else if (object.endCursor.length >= 0) + message.endCursor = object.endCursor; + switch (object.moreResults) { + default: + if (typeof object.moreResults === "number") { + message.moreResults = object.moreResults; + break; + } + break; + case "MORE_RESULTS_TYPE_UNSPECIFIED": + case 0: + message.moreResults = 0; + break; + case "NOT_FINISHED": + case 1: + message.moreResults = 1; + break; + case "MORE_RESULTS_AFTER_LIMIT": + case 2: + message.moreResults = 2; + break; + case "MORE_RESULTS_AFTER_CURSOR": + case 4: + message.moreResults = 4; + break; + case "NO_MORE_RESULTS": + case 3: + message.moreResults = 3; + break; + } + if (object.snapshotVersion != null) + if ($util.Long) + (message.snapshotVersion = $util.Long.fromValue(object.snapshotVersion)).unsigned = false; + else if (typeof object.snapshotVersion === "string") + message.snapshotVersion = parseInt(object.snapshotVersion, 10); + else if (typeof object.snapshotVersion === "number") + message.snapshotVersion = object.snapshotVersion; + else if (typeof object.snapshotVersion === "object") + message.snapshotVersion = new $util.LongBits(object.snapshotVersion.low >>> 0, object.snapshotVersion.high >>> 0).toNumber(); + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.datastore.v1.QueryResultBatch.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a QueryResultBatch message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {google.datastore.v1.QueryResultBatch} message QueryResultBatch + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + QueryResultBatch.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.entityResults = []; + if (options.defaults) { + object.entityResultType = options.enums === String ? "RESULT_TYPE_UNSPECIFIED" : 0; + if (options.bytes === String) + object.skippedCursor = ""; + else { + object.skippedCursor = []; + if (options.bytes !== Array) + object.skippedCursor = $util.newBuffer(object.skippedCursor); + } + if (options.bytes === String) + object.endCursor = ""; + else { + object.endCursor = []; + if (options.bytes !== Array) + object.endCursor = $util.newBuffer(object.endCursor); + } + object.moreResults = options.enums === String ? "MORE_RESULTS_TYPE_UNSPECIFIED" : 0; + object.skippedResults = 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.snapshotVersion = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.snapshotVersion = options.longs === String ? "0" : 0; + object.readTime = null; + } + if (message.entityResultType != null && message.hasOwnProperty("entityResultType")) + object.entityResultType = options.enums === String ? $root.google.datastore.v1.EntityResult.ResultType[message.entityResultType] === undefined ? message.entityResultType : $root.google.datastore.v1.EntityResult.ResultType[message.entityResultType] : message.entityResultType; + if (message.entityResults && message.entityResults.length) { + object.entityResults = []; + for (var j = 0; j < message.entityResults.length; ++j) + object.entityResults[j] = $root.google.datastore.v1.EntityResult.toObject(message.entityResults[j], options); + } + if (message.skippedCursor != null && message.hasOwnProperty("skippedCursor")) + object.skippedCursor = options.bytes === String ? $util.base64.encode(message.skippedCursor, 0, message.skippedCursor.length) : options.bytes === Array ? Array.prototype.slice.call(message.skippedCursor) : message.skippedCursor; + if (message.endCursor != null && message.hasOwnProperty("endCursor")) + object.endCursor = options.bytes === String ? $util.base64.encode(message.endCursor, 0, message.endCursor.length) : options.bytes === Array ? Array.prototype.slice.call(message.endCursor) : message.endCursor; + if (message.moreResults != null && message.hasOwnProperty("moreResults")) + object.moreResults = options.enums === String ? $root.google.datastore.v1.QueryResultBatch.MoreResultsType[message.moreResults] === undefined ? message.moreResults : $root.google.datastore.v1.QueryResultBatch.MoreResultsType[message.moreResults] : message.moreResults; + if (message.skippedResults != null && message.hasOwnProperty("skippedResults")) + object.skippedResults = message.skippedResults; + if (message.snapshotVersion != null && message.hasOwnProperty("snapshotVersion")) + if (typeof message.snapshotVersion === "number") + object.snapshotVersion = options.longs === String ? String(message.snapshotVersion) : message.snapshotVersion; + else + object.snapshotVersion = options.longs === String ? $util.Long.prototype.toString.call(message.snapshotVersion) : options.longs === Number ? new $util.LongBits(message.snapshotVersion.low >>> 0, message.snapshotVersion.high >>> 0).toNumber() : message.snapshotVersion; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this QueryResultBatch to JSON. + * @function toJSON + * @memberof google.datastore.v1.QueryResultBatch + * @instance + * @returns {Object.} JSON object + */ + QueryResultBatch.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for QueryResultBatch + * @function getTypeUrl + * @memberof google.datastore.v1.QueryResultBatch + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + QueryResultBatch.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.QueryResultBatch"; + }; + + /** + * MoreResultsType enum. + * @name google.datastore.v1.QueryResultBatch.MoreResultsType + * @enum {number} + * @property {number} MORE_RESULTS_TYPE_UNSPECIFIED=0 MORE_RESULTS_TYPE_UNSPECIFIED value + * @property {number} NOT_FINISHED=1 NOT_FINISHED value + * @property {number} MORE_RESULTS_AFTER_LIMIT=2 MORE_RESULTS_AFTER_LIMIT value + * @property {number} MORE_RESULTS_AFTER_CURSOR=4 MORE_RESULTS_AFTER_CURSOR value + * @property {number} NO_MORE_RESULTS=3 NO_MORE_RESULTS value + */ + QueryResultBatch.MoreResultsType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MORE_RESULTS_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "NOT_FINISHED"] = 1; + values[valuesById[2] = "MORE_RESULTS_AFTER_LIMIT"] = 2; + values[valuesById[4] = "MORE_RESULTS_AFTER_CURSOR"] = 4; + values[valuesById[3] = "NO_MORE_RESULTS"] = 3; + return values; + })(); + + return QueryResultBatch; + })(); + + v1.Datastore = (function() { + + /** + * Constructs a new Datastore service. + * @memberof google.datastore.v1 + * @classdesc Represents a Datastore + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Datastore(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Datastore.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Datastore; + + /** + * Creates new Datastore service using the specified rpc implementation. + * @function create + * @memberof google.datastore.v1.Datastore + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {Datastore} RPC service. Useful where requests and/or responses are streamed. + */ + Datastore.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.datastore.v1.Datastore|lookup}. + * @memberof google.datastore.v1.Datastore + * @typedef LookupCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.LookupResponse} [response] LookupResponse + */ + + /** + * Calls Lookup. + * @function lookup + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.ILookupRequest} request LookupRequest message or plain object + * @param {google.datastore.v1.Datastore.LookupCallback} callback Node-style callback called with the error, if any, and LookupResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.lookup = function lookup(request, callback) { + return this.rpcCall(lookup, $root.google.datastore.v1.LookupRequest, $root.google.datastore.v1.LookupResponse, request, callback); + }, "name", { value: "Lookup" }); + + /** + * Calls Lookup. + * @function lookup + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.ILookupRequest} request LookupRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.v1.Datastore|runQuery}. + * @memberof google.datastore.v1.Datastore + * @typedef RunQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.RunQueryResponse} [response] RunQueryResponse + */ + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IRunQueryRequest} request RunQueryRequest message or plain object + * @param {google.datastore.v1.Datastore.RunQueryCallback} callback Node-style callback called with the error, if any, and RunQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.runQuery = function runQuery(request, callback) { + return this.rpcCall(runQuery, $root.google.datastore.v1.RunQueryRequest, $root.google.datastore.v1.RunQueryResponse, request, callback); + }, "name", { value: "RunQuery" }); + + /** + * Calls RunQuery. + * @function runQuery + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IRunQueryRequest} request RunQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.v1.Datastore|runAggregationQuery}. + * @memberof google.datastore.v1.Datastore + * @typedef RunAggregationQueryCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.RunAggregationQueryResponse} [response] RunAggregationQueryResponse + */ + + /** + * Calls RunAggregationQuery. + * @function runAggregationQuery + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IRunAggregationQueryRequest} request RunAggregationQueryRequest message or plain object + * @param {google.datastore.v1.Datastore.RunAggregationQueryCallback} callback Node-style callback called with the error, if any, and RunAggregationQueryResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.runAggregationQuery = function runAggregationQuery(request, callback) { + return this.rpcCall(runAggregationQuery, $root.google.datastore.v1.RunAggregationQueryRequest, $root.google.datastore.v1.RunAggregationQueryResponse, request, callback); + }, "name", { value: "RunAggregationQuery" }); + + /** + * Calls RunAggregationQuery. + * @function runAggregationQuery + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IRunAggregationQueryRequest} request RunAggregationQueryRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.v1.Datastore|beginTransaction}. + * @memberof google.datastore.v1.Datastore + * @typedef BeginTransactionCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.BeginTransactionResponse} [response] BeginTransactionResponse + */ + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @param {google.datastore.v1.Datastore.BeginTransactionCallback} callback Node-style callback called with the error, if any, and BeginTransactionResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.beginTransaction = function beginTransaction(request, callback) { + return this.rpcCall(beginTransaction, $root.google.datastore.v1.BeginTransactionRequest, $root.google.datastore.v1.BeginTransactionResponse, request, callback); + }, "name", { value: "BeginTransaction" }); + + /** + * Calls BeginTransaction. + * @function beginTransaction + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IBeginTransactionRequest} request BeginTransactionRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.v1.Datastore|commit}. + * @memberof google.datastore.v1.Datastore + * @typedef CommitCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.CommitResponse} [response] CommitResponse + */ + + /** + * Calls Commit. + * @function commit + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.ICommitRequest} request CommitRequest message or plain object + * @param {google.datastore.v1.Datastore.CommitCallback} callback Node-style callback called with the error, if any, and CommitResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.commit = function commit(request, callback) { + return this.rpcCall(commit, $root.google.datastore.v1.CommitRequest, $root.google.datastore.v1.CommitResponse, request, callback); + }, "name", { value: "Commit" }); + + /** + * Calls Commit. + * @function commit + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.ICommitRequest} request CommitRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.v1.Datastore|rollback}. + * @memberof google.datastore.v1.Datastore + * @typedef RollbackCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.RollbackResponse} [response] RollbackResponse + */ + + /** + * Calls Rollback. + * @function rollback + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IRollbackRequest} request RollbackRequest message or plain object + * @param {google.datastore.v1.Datastore.RollbackCallback} callback Node-style callback called with the error, if any, and RollbackResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.rollback = function rollback(request, callback) { + return this.rpcCall(rollback, $root.google.datastore.v1.RollbackRequest, $root.google.datastore.v1.RollbackResponse, request, callback); + }, "name", { value: "Rollback" }); + + /** + * Calls Rollback. + * @function rollback + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IRollbackRequest} request RollbackRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.v1.Datastore|allocateIds}. + * @memberof google.datastore.v1.Datastore + * @typedef AllocateIdsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.AllocateIdsResponse} [response] AllocateIdsResponse + */ + + /** + * Calls AllocateIds. + * @function allocateIds + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IAllocateIdsRequest} request AllocateIdsRequest message or plain object + * @param {google.datastore.v1.Datastore.AllocateIdsCallback} callback Node-style callback called with the error, if any, and AllocateIdsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.allocateIds = function allocateIds(request, callback) { + return this.rpcCall(allocateIds, $root.google.datastore.v1.AllocateIdsRequest, $root.google.datastore.v1.AllocateIdsResponse, request, callback); + }, "name", { value: "AllocateIds" }); + + /** + * Calls AllocateIds. + * @function allocateIds + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IAllocateIdsRequest} request AllocateIdsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.datastore.v1.Datastore|reserveIds}. + * @memberof google.datastore.v1.Datastore + * @typedef ReserveIdsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.datastore.v1.ReserveIdsResponse} [response] ReserveIdsResponse + */ + + /** + * Calls ReserveIds. + * @function reserveIds + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IReserveIdsRequest} request ReserveIdsRequest message or plain object + * @param {google.datastore.v1.Datastore.ReserveIdsCallback} callback Node-style callback called with the error, if any, and ReserveIdsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Datastore.prototype.reserveIds = function reserveIds(request, callback) { + return this.rpcCall(reserveIds, $root.google.datastore.v1.ReserveIdsRequest, $root.google.datastore.v1.ReserveIdsResponse, request, callback); + }, "name", { value: "ReserveIds" }); + + /** + * Calls ReserveIds. + * @function reserveIds + * @memberof google.datastore.v1.Datastore + * @instance + * @param {google.datastore.v1.IReserveIdsRequest} request ReserveIdsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Datastore; + })(); + + v1.LookupRequest = (function() { + + /** + * Properties of a LookupRequest. + * @memberof google.datastore.v1 + * @interface ILookupRequest + * @property {string|null} [projectId] LookupRequest projectId + * @property {string|null} [databaseId] LookupRequest databaseId + * @property {google.datastore.v1.IReadOptions|null} [readOptions] LookupRequest readOptions + * @property {Array.|null} [keys] LookupRequest keys + * @property {google.datastore.v1.IPropertyMask|null} [propertyMask] LookupRequest propertyMask + */ + + /** + * Constructs a new LookupRequest. + * @memberof google.datastore.v1 + * @classdesc Represents a LookupRequest. + * @implements ILookupRequest + * @constructor + * @param {google.datastore.v1.ILookupRequest=} [properties] Properties to set + */ + function LookupRequest(properties) { + this.keys = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LookupRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.LookupRequest + * @instance + */ + LookupRequest.prototype.projectId = ""; + + /** + * LookupRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.LookupRequest + * @instance + */ + LookupRequest.prototype.databaseId = ""; + + /** + * LookupRequest readOptions. + * @member {google.datastore.v1.IReadOptions|null|undefined} readOptions + * @memberof google.datastore.v1.LookupRequest + * @instance + */ + LookupRequest.prototype.readOptions = null; + + /** + * LookupRequest keys. + * @member {Array.} keys + * @memberof google.datastore.v1.LookupRequest + * @instance + */ + LookupRequest.prototype.keys = $util.emptyArray; + + /** + * LookupRequest propertyMask. + * @member {google.datastore.v1.IPropertyMask|null|undefined} propertyMask + * @memberof google.datastore.v1.LookupRequest + * @instance + */ + LookupRequest.prototype.propertyMask = null; + + /** + * Creates a new LookupRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {google.datastore.v1.ILookupRequest=} [properties] Properties to set + * @returns {google.datastore.v1.LookupRequest} LookupRequest instance + */ + LookupRequest.create = function create(properties) { + return new LookupRequest(properties); + }; + + /** + * Encodes the specified LookupRequest message. Does not implicitly {@link google.datastore.v1.LookupRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {google.datastore.v1.ILookupRequest} message LookupRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LookupRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readOptions != null && Object.hasOwnProperty.call(message, "readOptions")) + $root.google.datastore.v1.ReadOptions.encode(message.readOptions, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.keys != null && message.keys.length) + for (var i = 0; i < message.keys.length; ++i) + $root.google.datastore.v1.Key.encode(message.keys[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.propertyMask != null && Object.hasOwnProperty.call(message, "propertyMask")) + $root.google.datastore.v1.PropertyMask.encode(message.propertyMask, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + return writer; + }; + + /** + * Encodes the specified LookupRequest message, length delimited. Does not implicitly {@link google.datastore.v1.LookupRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {google.datastore.v1.ILookupRequest} message LookupRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LookupRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LookupRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.LookupRequest} LookupRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LookupRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.LookupRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 1: { + message.readOptions = $root.google.datastore.v1.ReadOptions.decode(reader, reader.uint32()); + break; + } + case 3: { + if (!(message.keys && message.keys.length)) + message.keys = []; + message.keys.push($root.google.datastore.v1.Key.decode(reader, reader.uint32())); + break; + } + case 5: { + message.propertyMask = $root.google.datastore.v1.PropertyMask.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LookupRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.LookupRequest} LookupRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LookupRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LookupRequest message. + * @function verify + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LookupRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.readOptions != null && message.hasOwnProperty("readOptions")) { + var error = $root.google.datastore.v1.ReadOptions.verify(message.readOptions); + if (error) + return "readOptions." + error; + } + if (message.keys != null && message.hasOwnProperty("keys")) { + if (!Array.isArray(message.keys)) + return "keys: array expected"; + for (var i = 0; i < message.keys.length; ++i) { + var error = $root.google.datastore.v1.Key.verify(message.keys[i]); + if (error) + return "keys." + error; + } + } + if (message.propertyMask != null && message.hasOwnProperty("propertyMask")) { + var error = $root.google.datastore.v1.PropertyMask.verify(message.propertyMask); + if (error) + return "propertyMask." + error; + } + return null; + }; + + /** + * Creates a LookupRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.LookupRequest} LookupRequest + */ + LookupRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.LookupRequest) + return object; + var message = new $root.google.datastore.v1.LookupRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.readOptions != null) { + if (typeof object.readOptions !== "object") + throw TypeError(".google.datastore.v1.LookupRequest.readOptions: object expected"); + message.readOptions = $root.google.datastore.v1.ReadOptions.fromObject(object.readOptions); + } + if (object.keys) { + if (!Array.isArray(object.keys)) + throw TypeError(".google.datastore.v1.LookupRequest.keys: array expected"); + message.keys = []; + for (var i = 0; i < object.keys.length; ++i) { + if (typeof object.keys[i] !== "object") + throw TypeError(".google.datastore.v1.LookupRequest.keys: object expected"); + message.keys[i] = $root.google.datastore.v1.Key.fromObject(object.keys[i]); + } + } + if (object.propertyMask != null) { + if (typeof object.propertyMask !== "object") + throw TypeError(".google.datastore.v1.LookupRequest.propertyMask: object expected"); + message.propertyMask = $root.google.datastore.v1.PropertyMask.fromObject(object.propertyMask); + } + return message; + }; + + /** + * Creates a plain object from a LookupRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {google.datastore.v1.LookupRequest} message LookupRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LookupRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.keys = []; + if (options.defaults) { + object.readOptions = null; + object.propertyMask = null; + object.projectId = ""; + object.databaseId = ""; + } + if (message.readOptions != null && message.hasOwnProperty("readOptions")) + object.readOptions = $root.google.datastore.v1.ReadOptions.toObject(message.readOptions, options); + if (message.keys && message.keys.length) { + object.keys = []; + for (var j = 0; j < message.keys.length; ++j) + object.keys[j] = $root.google.datastore.v1.Key.toObject(message.keys[j], options); + } + if (message.propertyMask != null && message.hasOwnProperty("propertyMask")) + object.propertyMask = $root.google.datastore.v1.PropertyMask.toObject(message.propertyMask, options); + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + return object; + }; + + /** + * Converts this LookupRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.LookupRequest + * @instance + * @returns {Object.} JSON object + */ + LookupRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LookupRequest + * @function getTypeUrl + * @memberof google.datastore.v1.LookupRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LookupRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.LookupRequest"; + }; + + return LookupRequest; + })(); + + v1.LookupResponse = (function() { + + /** + * Properties of a LookupResponse. + * @memberof google.datastore.v1 + * @interface ILookupResponse + * @property {Array.|null} [found] LookupResponse found + * @property {Array.|null} [missing] LookupResponse missing + * @property {Array.|null} [deferred] LookupResponse deferred + * @property {Uint8Array|null} [transaction] LookupResponse transaction + * @property {google.protobuf.ITimestamp|null} [readTime] LookupResponse readTime + */ + + /** + * Constructs a new LookupResponse. + * @memberof google.datastore.v1 + * @classdesc Represents a LookupResponse. + * @implements ILookupResponse + * @constructor + * @param {google.datastore.v1.ILookupResponse=} [properties] Properties to set + */ + function LookupResponse(properties) { + this.found = []; + this.missing = []; + this.deferred = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LookupResponse found. + * @member {Array.} found + * @memberof google.datastore.v1.LookupResponse + * @instance + */ + LookupResponse.prototype.found = $util.emptyArray; + + /** + * LookupResponse missing. + * @member {Array.} missing + * @memberof google.datastore.v1.LookupResponse + * @instance + */ + LookupResponse.prototype.missing = $util.emptyArray; + + /** + * LookupResponse deferred. + * @member {Array.} deferred + * @memberof google.datastore.v1.LookupResponse + * @instance + */ + LookupResponse.prototype.deferred = $util.emptyArray; + + /** + * LookupResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.LookupResponse + * @instance + */ + LookupResponse.prototype.transaction = $util.newBuffer([]); + + /** + * LookupResponse readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.datastore.v1.LookupResponse + * @instance + */ + LookupResponse.prototype.readTime = null; + + /** + * Creates a new LookupResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {google.datastore.v1.ILookupResponse=} [properties] Properties to set + * @returns {google.datastore.v1.LookupResponse} LookupResponse instance + */ + LookupResponse.create = function create(properties) { + return new LookupResponse(properties); + }; + + /** + * Encodes the specified LookupResponse message. Does not implicitly {@link google.datastore.v1.LookupResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {google.datastore.v1.ILookupResponse} message LookupResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LookupResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.found != null && message.found.length) + for (var i = 0; i < message.found.length; ++i) + $root.google.datastore.v1.EntityResult.encode(message.found[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.missing != null && message.missing.length) + for (var i = 0; i < message.missing.length; ++i) + $root.google.datastore.v1.EntityResult.encode(message.missing[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.deferred != null && message.deferred.length) + for (var i = 0; i < message.deferred.length; ++i) + $root.google.datastore.v1.Key.encode(message.deferred[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.transaction); + if (message.readTime != null && Object.hasOwnProperty.call(message, "readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified LookupResponse message, length delimited. Does not implicitly {@link google.datastore.v1.LookupResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {google.datastore.v1.ILookupResponse} message LookupResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LookupResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LookupResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.LookupResponse} LookupResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LookupResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.LookupResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.found && message.found.length)) + message.found = []; + message.found.push($root.google.datastore.v1.EntityResult.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.missing && message.missing.length)) + message.missing = []; + message.missing.push($root.google.datastore.v1.EntityResult.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.deferred && message.deferred.length)) + message.deferred = []; + message.deferred.push($root.google.datastore.v1.Key.decode(reader, reader.uint32())); + break; + } + case 5: { + message.transaction = reader.bytes(); + break; + } + case 7: { + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LookupResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.LookupResponse} LookupResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LookupResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LookupResponse message. + * @function verify + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LookupResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.found != null && message.hasOwnProperty("found")) { + if (!Array.isArray(message.found)) + return "found: array expected"; + for (var i = 0; i < message.found.length; ++i) { + var error = $root.google.datastore.v1.EntityResult.verify(message.found[i]); + if (error) + return "found." + error; + } + } + if (message.missing != null && message.hasOwnProperty("missing")) { + if (!Array.isArray(message.missing)) + return "missing: array expected"; + for (var i = 0; i < message.missing.length; ++i) { + var error = $root.google.datastore.v1.EntityResult.verify(message.missing[i]); + if (error) + return "missing." + error; + } + } + if (message.deferred != null && message.hasOwnProperty("deferred")) { + if (!Array.isArray(message.deferred)) + return "deferred: array expected"; + for (var i = 0; i < message.deferred.length; ++i) { + var error = $root.google.datastore.v1.Key.verify(message.deferred[i]); + if (error) + return "deferred." + error; + } + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return null; + }; + + /** + * Creates a LookupResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.LookupResponse} LookupResponse + */ + LookupResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.LookupResponse) + return object; + var message = new $root.google.datastore.v1.LookupResponse(); + if (object.found) { + if (!Array.isArray(object.found)) + throw TypeError(".google.datastore.v1.LookupResponse.found: array expected"); + message.found = []; + for (var i = 0; i < object.found.length; ++i) { + if (typeof object.found[i] !== "object") + throw TypeError(".google.datastore.v1.LookupResponse.found: object expected"); + message.found[i] = $root.google.datastore.v1.EntityResult.fromObject(object.found[i]); + } + } + if (object.missing) { + if (!Array.isArray(object.missing)) + throw TypeError(".google.datastore.v1.LookupResponse.missing: array expected"); + message.missing = []; + for (var i = 0; i < object.missing.length; ++i) { + if (typeof object.missing[i] !== "object") + throw TypeError(".google.datastore.v1.LookupResponse.missing: object expected"); + message.missing[i] = $root.google.datastore.v1.EntityResult.fromObject(object.missing[i]); + } + } + if (object.deferred) { + if (!Array.isArray(object.deferred)) + throw TypeError(".google.datastore.v1.LookupResponse.deferred: array expected"); + message.deferred = []; + for (var i = 0; i < object.deferred.length; ++i) { + if (typeof object.deferred[i] !== "object") + throw TypeError(".google.datastore.v1.LookupResponse.deferred: object expected"); + message.deferred[i] = $root.google.datastore.v1.Key.fromObject(object.deferred[i]); + } + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.datastore.v1.LookupResponse.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a LookupResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {google.datastore.v1.LookupResponse} message LookupResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LookupResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.found = []; + object.missing = []; + object.deferred = []; + } + if (options.defaults) { + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.readTime = null; + } + if (message.found && message.found.length) { + object.found = []; + for (var j = 0; j < message.found.length; ++j) + object.found[j] = $root.google.datastore.v1.EntityResult.toObject(message.found[j], options); + } + if (message.missing && message.missing.length) { + object.missing = []; + for (var j = 0; j < message.missing.length; ++j) + object.missing[j] = $root.google.datastore.v1.EntityResult.toObject(message.missing[j], options); + } + if (message.deferred && message.deferred.length) { + object.deferred = []; + for (var j = 0; j < message.deferred.length; ++j) + object.deferred[j] = $root.google.datastore.v1.Key.toObject(message.deferred[j], options); + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this LookupResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.LookupResponse + * @instance + * @returns {Object.} JSON object + */ + LookupResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LookupResponse + * @function getTypeUrl + * @memberof google.datastore.v1.LookupResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LookupResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.LookupResponse"; + }; + + return LookupResponse; + })(); + + v1.RunQueryRequest = (function() { + + /** + * Properties of a RunQueryRequest. + * @memberof google.datastore.v1 + * @interface IRunQueryRequest + * @property {string|null} [projectId] RunQueryRequest projectId + * @property {string|null} [databaseId] RunQueryRequest databaseId + * @property {google.datastore.v1.IPartitionId|null} [partitionId] RunQueryRequest partitionId + * @property {google.datastore.v1.IReadOptions|null} [readOptions] RunQueryRequest readOptions + * @property {google.datastore.v1.IQuery|null} [query] RunQueryRequest query + * @property {google.datastore.v1.IGqlQuery|null} [gqlQuery] RunQueryRequest gqlQuery + * @property {google.datastore.v1.IPropertyMask|null} [propertyMask] RunQueryRequest propertyMask + * @property {google.datastore.v1.IExplainOptions|null} [explainOptions] RunQueryRequest explainOptions + */ + + /** + * Constructs a new RunQueryRequest. + * @memberof google.datastore.v1 + * @classdesc Represents a RunQueryRequest. + * @implements IRunQueryRequest + * @constructor + * @param {google.datastore.v1.IRunQueryRequest=} [properties] Properties to set + */ + function RunQueryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.projectId = ""; + + /** + * RunQueryRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.databaseId = ""; + + /** + * RunQueryRequest partitionId. + * @member {google.datastore.v1.IPartitionId|null|undefined} partitionId + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.partitionId = null; + + /** + * RunQueryRequest readOptions. + * @member {google.datastore.v1.IReadOptions|null|undefined} readOptions + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.readOptions = null; + + /** + * RunQueryRequest query. + * @member {google.datastore.v1.IQuery|null|undefined} query + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.query = null; + + /** + * RunQueryRequest gqlQuery. + * @member {google.datastore.v1.IGqlQuery|null|undefined} gqlQuery + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.gqlQuery = null; + + /** + * RunQueryRequest propertyMask. + * @member {google.datastore.v1.IPropertyMask|null|undefined} propertyMask + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.propertyMask = null; + + /** + * RunQueryRequest explainOptions. + * @member {google.datastore.v1.IExplainOptions|null|undefined} explainOptions + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + RunQueryRequest.prototype.explainOptions = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RunQueryRequest queryType. + * @member {"query"|"gqlQuery"|undefined} queryType + * @memberof google.datastore.v1.RunQueryRequest + * @instance + */ + Object.defineProperty(RunQueryRequest.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["query", "gqlQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new RunQueryRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {google.datastore.v1.IRunQueryRequest=} [properties] Properties to set + * @returns {google.datastore.v1.RunQueryRequest} RunQueryRequest instance + */ + RunQueryRequest.create = function create(properties) { + return new RunQueryRequest(properties); + }; + + /** + * Encodes the specified RunQueryRequest message. Does not implicitly {@link google.datastore.v1.RunQueryRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {google.datastore.v1.IRunQueryRequest} message RunQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readOptions != null && Object.hasOwnProperty.call(message, "readOptions")) + $root.google.datastore.v1.ReadOptions.encode(message.readOptions, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.partitionId != null && Object.hasOwnProperty.call(message, "partitionId")) + $root.google.datastore.v1.PartitionId.encode(message.partitionId, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + $root.google.datastore.v1.Query.encode(message.query, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.gqlQuery != null && Object.hasOwnProperty.call(message, "gqlQuery")) + $root.google.datastore.v1.GqlQuery.encode(message.gqlQuery, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + if (message.propertyMask != null && Object.hasOwnProperty.call(message, "propertyMask")) + $root.google.datastore.v1.PropertyMask.encode(message.propertyMask, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + if (message.explainOptions != null && Object.hasOwnProperty.call(message, "explainOptions")) + $root.google.datastore.v1.ExplainOptions.encode(message.explainOptions, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RunQueryRequest message, length delimited. Does not implicitly {@link google.datastore.v1.RunQueryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {google.datastore.v1.IRunQueryRequest} message RunQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.RunQueryRequest} RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.RunQueryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 2: { + message.partitionId = $root.google.datastore.v1.PartitionId.decode(reader, reader.uint32()); + break; + } + case 1: { + message.readOptions = $root.google.datastore.v1.ReadOptions.decode(reader, reader.uint32()); + break; + } + case 3: { + message.query = $root.google.datastore.v1.Query.decode(reader, reader.uint32()); + break; + } + case 7: { + message.gqlQuery = $root.google.datastore.v1.GqlQuery.decode(reader, reader.uint32()); + break; + } + case 10: { + message.propertyMask = $root.google.datastore.v1.PropertyMask.decode(reader, reader.uint32()); + break; + } + case 12: { + message.explainOptions = $root.google.datastore.v1.ExplainOptions.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RunQueryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.RunQueryRequest} RunQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RunQueryRequest message. + * @function verify + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RunQueryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.partitionId != null && message.hasOwnProperty("partitionId")) { + var error = $root.google.datastore.v1.PartitionId.verify(message.partitionId); + if (error) + return "partitionId." + error; + } + if (message.readOptions != null && message.hasOwnProperty("readOptions")) { + var error = $root.google.datastore.v1.ReadOptions.verify(message.readOptions); + if (error) + return "readOptions." + error; + } + if (message.query != null && message.hasOwnProperty("query")) { + properties.queryType = 1; + { + var error = $root.google.datastore.v1.Query.verify(message.query); + if (error) + return "query." + error; + } + } + if (message.gqlQuery != null && message.hasOwnProperty("gqlQuery")) { + if (properties.queryType === 1) + return "queryType: multiple values"; + properties.queryType = 1; + { + var error = $root.google.datastore.v1.GqlQuery.verify(message.gqlQuery); + if (error) + return "gqlQuery." + error; + } + } + if (message.propertyMask != null && message.hasOwnProperty("propertyMask")) { + var error = $root.google.datastore.v1.PropertyMask.verify(message.propertyMask); + if (error) + return "propertyMask." + error; + } + if (message.explainOptions != null && message.hasOwnProperty("explainOptions")) { + var error = $root.google.datastore.v1.ExplainOptions.verify(message.explainOptions); + if (error) + return "explainOptions." + error; + } + return null; + }; + + /** + * Creates a RunQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.RunQueryRequest} RunQueryRequest + */ + RunQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.RunQueryRequest) + return object; + var message = new $root.google.datastore.v1.RunQueryRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.partitionId != null) { + if (typeof object.partitionId !== "object") + throw TypeError(".google.datastore.v1.RunQueryRequest.partitionId: object expected"); + message.partitionId = $root.google.datastore.v1.PartitionId.fromObject(object.partitionId); + } + if (object.readOptions != null) { + if (typeof object.readOptions !== "object") + throw TypeError(".google.datastore.v1.RunQueryRequest.readOptions: object expected"); + message.readOptions = $root.google.datastore.v1.ReadOptions.fromObject(object.readOptions); + } + if (object.query != null) { + if (typeof object.query !== "object") + throw TypeError(".google.datastore.v1.RunQueryRequest.query: object expected"); + message.query = $root.google.datastore.v1.Query.fromObject(object.query); + } + if (object.gqlQuery != null) { + if (typeof object.gqlQuery !== "object") + throw TypeError(".google.datastore.v1.RunQueryRequest.gqlQuery: object expected"); + message.gqlQuery = $root.google.datastore.v1.GqlQuery.fromObject(object.gqlQuery); + } + if (object.propertyMask != null) { + if (typeof object.propertyMask !== "object") + throw TypeError(".google.datastore.v1.RunQueryRequest.propertyMask: object expected"); + message.propertyMask = $root.google.datastore.v1.PropertyMask.fromObject(object.propertyMask); + } + if (object.explainOptions != null) { + if (typeof object.explainOptions !== "object") + throw TypeError(".google.datastore.v1.RunQueryRequest.explainOptions: object expected"); + message.explainOptions = $root.google.datastore.v1.ExplainOptions.fromObject(object.explainOptions); + } + return message; + }; + + /** + * Creates a plain object from a RunQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {google.datastore.v1.RunQueryRequest} message RunQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.readOptions = null; + object.partitionId = null; + object.projectId = ""; + object.databaseId = ""; + object.propertyMask = null; + object.explainOptions = null; + } + if (message.readOptions != null && message.hasOwnProperty("readOptions")) + object.readOptions = $root.google.datastore.v1.ReadOptions.toObject(message.readOptions, options); + if (message.partitionId != null && message.hasOwnProperty("partitionId")) + object.partitionId = $root.google.datastore.v1.PartitionId.toObject(message.partitionId, options); + if (message.query != null && message.hasOwnProperty("query")) { + object.query = $root.google.datastore.v1.Query.toObject(message.query, options); + if (options.oneofs) + object.queryType = "query"; + } + if (message.gqlQuery != null && message.hasOwnProperty("gqlQuery")) { + object.gqlQuery = $root.google.datastore.v1.GqlQuery.toObject(message.gqlQuery, options); + if (options.oneofs) + object.queryType = "gqlQuery"; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + if (message.propertyMask != null && message.hasOwnProperty("propertyMask")) + object.propertyMask = $root.google.datastore.v1.PropertyMask.toObject(message.propertyMask, options); + if (message.explainOptions != null && message.hasOwnProperty("explainOptions")) + object.explainOptions = $root.google.datastore.v1.ExplainOptions.toObject(message.explainOptions, options); + return object; + }; + + /** + * Converts this RunQueryRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.RunQueryRequest + * @instance + * @returns {Object.} JSON object + */ + RunQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RunQueryRequest + * @function getTypeUrl + * @memberof google.datastore.v1.RunQueryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RunQueryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.RunQueryRequest"; + }; + + return RunQueryRequest; + })(); + + v1.RunQueryResponse = (function() { + + /** + * Properties of a RunQueryResponse. + * @memberof google.datastore.v1 + * @interface IRunQueryResponse + * @property {google.datastore.v1.IQueryResultBatch|null} [batch] RunQueryResponse batch + * @property {google.datastore.v1.IQuery|null} [query] RunQueryResponse query + * @property {Uint8Array|null} [transaction] RunQueryResponse transaction + * @property {google.datastore.v1.IExplainMetrics|null} [explainMetrics] RunQueryResponse explainMetrics + */ + + /** + * Constructs a new RunQueryResponse. + * @memberof google.datastore.v1 + * @classdesc Represents a RunQueryResponse. + * @implements IRunQueryResponse + * @constructor + * @param {google.datastore.v1.IRunQueryResponse=} [properties] Properties to set + */ + function RunQueryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunQueryResponse batch. + * @member {google.datastore.v1.IQueryResultBatch|null|undefined} batch + * @memberof google.datastore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.batch = null; + + /** + * RunQueryResponse query. + * @member {google.datastore.v1.IQuery|null|undefined} query + * @memberof google.datastore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.query = null; + + /** + * RunQueryResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.transaction = $util.newBuffer([]); + + /** + * RunQueryResponse explainMetrics. + * @member {google.datastore.v1.IExplainMetrics|null|undefined} explainMetrics + * @memberof google.datastore.v1.RunQueryResponse + * @instance + */ + RunQueryResponse.prototype.explainMetrics = null; + + /** + * Creates a new RunQueryResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {google.datastore.v1.IRunQueryResponse=} [properties] Properties to set + * @returns {google.datastore.v1.RunQueryResponse} RunQueryResponse instance + */ + RunQueryResponse.create = function create(properties) { + return new RunQueryResponse(properties); + }; + + /** + * Encodes the specified RunQueryResponse message. Does not implicitly {@link google.datastore.v1.RunQueryResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {google.datastore.v1.IRunQueryResponse} message RunQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.batch != null && Object.hasOwnProperty.call(message, "batch")) + $root.google.datastore.v1.QueryResultBatch.encode(message.batch, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + $root.google.datastore.v1.Query.encode(message.query, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.transaction); + if (message.explainMetrics != null && Object.hasOwnProperty.call(message, "explainMetrics")) + $root.google.datastore.v1.ExplainMetrics.encode(message.explainMetrics, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RunQueryResponse message, length delimited. Does not implicitly {@link google.datastore.v1.RunQueryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {google.datastore.v1.IRunQueryResponse} message RunQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunQueryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.RunQueryResponse} RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.RunQueryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.batch = $root.google.datastore.v1.QueryResultBatch.decode(reader, reader.uint32()); + break; + } + case 2: { + message.query = $root.google.datastore.v1.Query.decode(reader, reader.uint32()); + break; + } + case 5: { + message.transaction = reader.bytes(); + break; + } + case 9: { + message.explainMetrics = $root.google.datastore.v1.ExplainMetrics.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RunQueryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.RunQueryResponse} RunQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunQueryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RunQueryResponse message. + * @function verify + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RunQueryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.batch != null && message.hasOwnProperty("batch")) { + var error = $root.google.datastore.v1.QueryResultBatch.verify(message.batch); + if (error) + return "batch." + error; + } + if (message.query != null && message.hasOwnProperty("query")) { + var error = $root.google.datastore.v1.Query.verify(message.query); + if (error) + return "query." + error; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + if (message.explainMetrics != null && message.hasOwnProperty("explainMetrics")) { + var error = $root.google.datastore.v1.ExplainMetrics.verify(message.explainMetrics); + if (error) + return "explainMetrics." + error; + } + return null; + }; + + /** + * Creates a RunQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.RunQueryResponse} RunQueryResponse + */ + RunQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.RunQueryResponse) + return object; + var message = new $root.google.datastore.v1.RunQueryResponse(); + if (object.batch != null) { + if (typeof object.batch !== "object") + throw TypeError(".google.datastore.v1.RunQueryResponse.batch: object expected"); + message.batch = $root.google.datastore.v1.QueryResultBatch.fromObject(object.batch); + } + if (object.query != null) { + if (typeof object.query !== "object") + throw TypeError(".google.datastore.v1.RunQueryResponse.query: object expected"); + message.query = $root.google.datastore.v1.Query.fromObject(object.query); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; + if (object.explainMetrics != null) { + if (typeof object.explainMetrics !== "object") + throw TypeError(".google.datastore.v1.RunQueryResponse.explainMetrics: object expected"); + message.explainMetrics = $root.google.datastore.v1.ExplainMetrics.fromObject(object.explainMetrics); + } + return message; + }; + + /** + * Creates a plain object from a RunQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {google.datastore.v1.RunQueryResponse} message RunQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.batch = null; + object.query = null; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.explainMetrics = null; + } + if (message.batch != null && message.hasOwnProperty("batch")) + object.batch = $root.google.datastore.v1.QueryResultBatch.toObject(message.batch, options); + if (message.query != null && message.hasOwnProperty("query")) + object.query = $root.google.datastore.v1.Query.toObject(message.query, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.explainMetrics != null && message.hasOwnProperty("explainMetrics")) + object.explainMetrics = $root.google.datastore.v1.ExplainMetrics.toObject(message.explainMetrics, options); + return object; + }; + + /** + * Converts this RunQueryResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.RunQueryResponse + * @instance + * @returns {Object.} JSON object + */ + RunQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RunQueryResponse + * @function getTypeUrl + * @memberof google.datastore.v1.RunQueryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RunQueryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.RunQueryResponse"; + }; + + return RunQueryResponse; + })(); + + v1.RunAggregationQueryRequest = (function() { + + /** + * Properties of a RunAggregationQueryRequest. + * @memberof google.datastore.v1 + * @interface IRunAggregationQueryRequest + * @property {string|null} [projectId] RunAggregationQueryRequest projectId + * @property {string|null} [databaseId] RunAggregationQueryRequest databaseId + * @property {google.datastore.v1.IPartitionId|null} [partitionId] RunAggregationQueryRequest partitionId + * @property {google.datastore.v1.IReadOptions|null} [readOptions] RunAggregationQueryRequest readOptions + * @property {google.datastore.v1.IAggregationQuery|null} [aggregationQuery] RunAggregationQueryRequest aggregationQuery + * @property {google.datastore.v1.IGqlQuery|null} [gqlQuery] RunAggregationQueryRequest gqlQuery + * @property {google.datastore.v1.IExplainOptions|null} [explainOptions] RunAggregationQueryRequest explainOptions + */ + + /** + * Constructs a new RunAggregationQueryRequest. + * @memberof google.datastore.v1 + * @classdesc Represents a RunAggregationQueryRequest. + * @implements IRunAggregationQueryRequest + * @constructor + * @param {google.datastore.v1.IRunAggregationQueryRequest=} [properties] Properties to set + */ + function RunAggregationQueryRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunAggregationQueryRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + RunAggregationQueryRequest.prototype.projectId = ""; + + /** + * RunAggregationQueryRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + RunAggregationQueryRequest.prototype.databaseId = ""; + + /** + * RunAggregationQueryRequest partitionId. + * @member {google.datastore.v1.IPartitionId|null|undefined} partitionId + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + RunAggregationQueryRequest.prototype.partitionId = null; + + /** + * RunAggregationQueryRequest readOptions. + * @member {google.datastore.v1.IReadOptions|null|undefined} readOptions + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + RunAggregationQueryRequest.prototype.readOptions = null; + + /** + * RunAggregationQueryRequest aggregationQuery. + * @member {google.datastore.v1.IAggregationQuery|null|undefined} aggregationQuery + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + RunAggregationQueryRequest.prototype.aggregationQuery = null; + + /** + * RunAggregationQueryRequest gqlQuery. + * @member {google.datastore.v1.IGqlQuery|null|undefined} gqlQuery + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + RunAggregationQueryRequest.prototype.gqlQuery = null; + + /** + * RunAggregationQueryRequest explainOptions. + * @member {google.datastore.v1.IExplainOptions|null|undefined} explainOptions + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + RunAggregationQueryRequest.prototype.explainOptions = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RunAggregationQueryRequest queryType. + * @member {"aggregationQuery"|"gqlQuery"|undefined} queryType + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + */ + Object.defineProperty(RunAggregationQueryRequest.prototype, "queryType", { + get: $util.oneOfGetter($oneOfFields = ["aggregationQuery", "gqlQuery"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new RunAggregationQueryRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {google.datastore.v1.IRunAggregationQueryRequest=} [properties] Properties to set + * @returns {google.datastore.v1.RunAggregationQueryRequest} RunAggregationQueryRequest instance + */ + RunAggregationQueryRequest.create = function create(properties) { + return new RunAggregationQueryRequest(properties); + }; + + /** + * Encodes the specified RunAggregationQueryRequest message. Does not implicitly {@link google.datastore.v1.RunAggregationQueryRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {google.datastore.v1.IRunAggregationQueryRequest} message RunAggregationQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunAggregationQueryRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readOptions != null && Object.hasOwnProperty.call(message, "readOptions")) + $root.google.datastore.v1.ReadOptions.encode(message.readOptions, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.partitionId != null && Object.hasOwnProperty.call(message, "partitionId")) + $root.google.datastore.v1.PartitionId.encode(message.partitionId, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.aggregationQuery != null && Object.hasOwnProperty.call(message, "aggregationQuery")) + $root.google.datastore.v1.AggregationQuery.encode(message.aggregationQuery, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.gqlQuery != null && Object.hasOwnProperty.call(message, "gqlQuery")) + $root.google.datastore.v1.GqlQuery.encode(message.gqlQuery, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + if (message.explainOptions != null && Object.hasOwnProperty.call(message, "explainOptions")) + $root.google.datastore.v1.ExplainOptions.encode(message.explainOptions, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RunAggregationQueryRequest message, length delimited. Does not implicitly {@link google.datastore.v1.RunAggregationQueryRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {google.datastore.v1.IRunAggregationQueryRequest} message RunAggregationQueryRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunAggregationQueryRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RunAggregationQueryRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.RunAggregationQueryRequest} RunAggregationQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunAggregationQueryRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.RunAggregationQueryRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 2: { + message.partitionId = $root.google.datastore.v1.PartitionId.decode(reader, reader.uint32()); + break; + } + case 1: { + message.readOptions = $root.google.datastore.v1.ReadOptions.decode(reader, reader.uint32()); + break; + } + case 3: { + message.aggregationQuery = $root.google.datastore.v1.AggregationQuery.decode(reader, reader.uint32()); + break; + } + case 7: { + message.gqlQuery = $root.google.datastore.v1.GqlQuery.decode(reader, reader.uint32()); + break; + } + case 11: { + message.explainOptions = $root.google.datastore.v1.ExplainOptions.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RunAggregationQueryRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.RunAggregationQueryRequest} RunAggregationQueryRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunAggregationQueryRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RunAggregationQueryRequest message. + * @function verify + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RunAggregationQueryRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.partitionId != null && message.hasOwnProperty("partitionId")) { + var error = $root.google.datastore.v1.PartitionId.verify(message.partitionId); + if (error) + return "partitionId." + error; + } + if (message.readOptions != null && message.hasOwnProperty("readOptions")) { + var error = $root.google.datastore.v1.ReadOptions.verify(message.readOptions); + if (error) + return "readOptions." + error; + } + if (message.aggregationQuery != null && message.hasOwnProperty("aggregationQuery")) { + properties.queryType = 1; + { + var error = $root.google.datastore.v1.AggregationQuery.verify(message.aggregationQuery); + if (error) + return "aggregationQuery." + error; + } + } + if (message.gqlQuery != null && message.hasOwnProperty("gqlQuery")) { + if (properties.queryType === 1) + return "queryType: multiple values"; + properties.queryType = 1; + { + var error = $root.google.datastore.v1.GqlQuery.verify(message.gqlQuery); + if (error) + return "gqlQuery." + error; + } + } + if (message.explainOptions != null && message.hasOwnProperty("explainOptions")) { + var error = $root.google.datastore.v1.ExplainOptions.verify(message.explainOptions); + if (error) + return "explainOptions." + error; + } + return null; + }; + + /** + * Creates a RunAggregationQueryRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.RunAggregationQueryRequest} RunAggregationQueryRequest + */ + RunAggregationQueryRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.RunAggregationQueryRequest) + return object; + var message = new $root.google.datastore.v1.RunAggregationQueryRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.partitionId != null) { + if (typeof object.partitionId !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryRequest.partitionId: object expected"); + message.partitionId = $root.google.datastore.v1.PartitionId.fromObject(object.partitionId); + } + if (object.readOptions != null) { + if (typeof object.readOptions !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryRequest.readOptions: object expected"); + message.readOptions = $root.google.datastore.v1.ReadOptions.fromObject(object.readOptions); + } + if (object.aggregationQuery != null) { + if (typeof object.aggregationQuery !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryRequest.aggregationQuery: object expected"); + message.aggregationQuery = $root.google.datastore.v1.AggregationQuery.fromObject(object.aggregationQuery); + } + if (object.gqlQuery != null) { + if (typeof object.gqlQuery !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryRequest.gqlQuery: object expected"); + message.gqlQuery = $root.google.datastore.v1.GqlQuery.fromObject(object.gqlQuery); + } + if (object.explainOptions != null) { + if (typeof object.explainOptions !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryRequest.explainOptions: object expected"); + message.explainOptions = $root.google.datastore.v1.ExplainOptions.fromObject(object.explainOptions); + } + return message; + }; + + /** + * Creates a plain object from a RunAggregationQueryRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {google.datastore.v1.RunAggregationQueryRequest} message RunAggregationQueryRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunAggregationQueryRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.readOptions = null; + object.partitionId = null; + object.projectId = ""; + object.databaseId = ""; + object.explainOptions = null; + } + if (message.readOptions != null && message.hasOwnProperty("readOptions")) + object.readOptions = $root.google.datastore.v1.ReadOptions.toObject(message.readOptions, options); + if (message.partitionId != null && message.hasOwnProperty("partitionId")) + object.partitionId = $root.google.datastore.v1.PartitionId.toObject(message.partitionId, options); + if (message.aggregationQuery != null && message.hasOwnProperty("aggregationQuery")) { + object.aggregationQuery = $root.google.datastore.v1.AggregationQuery.toObject(message.aggregationQuery, options); + if (options.oneofs) + object.queryType = "aggregationQuery"; + } + if (message.gqlQuery != null && message.hasOwnProperty("gqlQuery")) { + object.gqlQuery = $root.google.datastore.v1.GqlQuery.toObject(message.gqlQuery, options); + if (options.oneofs) + object.queryType = "gqlQuery"; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + if (message.explainOptions != null && message.hasOwnProperty("explainOptions")) + object.explainOptions = $root.google.datastore.v1.ExplainOptions.toObject(message.explainOptions, options); + return object; + }; + + /** + * Converts this RunAggregationQueryRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @instance + * @returns {Object.} JSON object + */ + RunAggregationQueryRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RunAggregationQueryRequest + * @function getTypeUrl + * @memberof google.datastore.v1.RunAggregationQueryRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RunAggregationQueryRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.RunAggregationQueryRequest"; + }; + + return RunAggregationQueryRequest; + })(); + + v1.RunAggregationQueryResponse = (function() { + + /** + * Properties of a RunAggregationQueryResponse. + * @memberof google.datastore.v1 + * @interface IRunAggregationQueryResponse + * @property {google.datastore.v1.IAggregationResultBatch|null} [batch] RunAggregationQueryResponse batch + * @property {google.datastore.v1.IAggregationQuery|null} [query] RunAggregationQueryResponse query + * @property {Uint8Array|null} [transaction] RunAggregationQueryResponse transaction + * @property {google.datastore.v1.IExplainMetrics|null} [explainMetrics] RunAggregationQueryResponse explainMetrics + */ + + /** + * Constructs a new RunAggregationQueryResponse. + * @memberof google.datastore.v1 + * @classdesc Represents a RunAggregationQueryResponse. + * @implements IRunAggregationQueryResponse + * @constructor + * @param {google.datastore.v1.IRunAggregationQueryResponse=} [properties] Properties to set + */ + function RunAggregationQueryResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RunAggregationQueryResponse batch. + * @member {google.datastore.v1.IAggregationResultBatch|null|undefined} batch + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @instance + */ + RunAggregationQueryResponse.prototype.batch = null; + + /** + * RunAggregationQueryResponse query. + * @member {google.datastore.v1.IAggregationQuery|null|undefined} query + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @instance + */ + RunAggregationQueryResponse.prototype.query = null; + + /** + * RunAggregationQueryResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @instance + */ + RunAggregationQueryResponse.prototype.transaction = $util.newBuffer([]); + + /** + * RunAggregationQueryResponse explainMetrics. + * @member {google.datastore.v1.IExplainMetrics|null|undefined} explainMetrics + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @instance + */ + RunAggregationQueryResponse.prototype.explainMetrics = null; + + /** + * Creates a new RunAggregationQueryResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {google.datastore.v1.IRunAggregationQueryResponse=} [properties] Properties to set + * @returns {google.datastore.v1.RunAggregationQueryResponse} RunAggregationQueryResponse instance + */ + RunAggregationQueryResponse.create = function create(properties) { + return new RunAggregationQueryResponse(properties); + }; + + /** + * Encodes the specified RunAggregationQueryResponse message. Does not implicitly {@link google.datastore.v1.RunAggregationQueryResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {google.datastore.v1.IRunAggregationQueryResponse} message RunAggregationQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunAggregationQueryResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.batch != null && Object.hasOwnProperty.call(message, "batch")) + $root.google.datastore.v1.AggregationResultBatch.encode(message.batch, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.query != null && Object.hasOwnProperty.call(message, "query")) + $root.google.datastore.v1.AggregationQuery.encode(message.query, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 5, wireType 2 =*/42).bytes(message.transaction); + if (message.explainMetrics != null && Object.hasOwnProperty.call(message, "explainMetrics")) + $root.google.datastore.v1.ExplainMetrics.encode(message.explainMetrics, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RunAggregationQueryResponse message, length delimited. Does not implicitly {@link google.datastore.v1.RunAggregationQueryResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {google.datastore.v1.IRunAggregationQueryResponse} message RunAggregationQueryResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RunAggregationQueryResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RunAggregationQueryResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.RunAggregationQueryResponse} RunAggregationQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunAggregationQueryResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.RunAggregationQueryResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.batch = $root.google.datastore.v1.AggregationResultBatch.decode(reader, reader.uint32()); + break; + } + case 2: { + message.query = $root.google.datastore.v1.AggregationQuery.decode(reader, reader.uint32()); + break; + } + case 5: { + message.transaction = reader.bytes(); + break; + } + case 9: { + message.explainMetrics = $root.google.datastore.v1.ExplainMetrics.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RunAggregationQueryResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.RunAggregationQueryResponse} RunAggregationQueryResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RunAggregationQueryResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RunAggregationQueryResponse message. + * @function verify + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RunAggregationQueryResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.batch != null && message.hasOwnProperty("batch")) { + var error = $root.google.datastore.v1.AggregationResultBatch.verify(message.batch); + if (error) + return "batch." + error; + } + if (message.query != null && message.hasOwnProperty("query")) { + var error = $root.google.datastore.v1.AggregationQuery.verify(message.query); + if (error) + return "query." + error; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + if (message.explainMetrics != null && message.hasOwnProperty("explainMetrics")) { + var error = $root.google.datastore.v1.ExplainMetrics.verify(message.explainMetrics); + if (error) + return "explainMetrics." + error; + } + return null; + }; + + /** + * Creates a RunAggregationQueryResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.RunAggregationQueryResponse} RunAggregationQueryResponse + */ + RunAggregationQueryResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.RunAggregationQueryResponse) + return object; + var message = new $root.google.datastore.v1.RunAggregationQueryResponse(); + if (object.batch != null) { + if (typeof object.batch !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryResponse.batch: object expected"); + message.batch = $root.google.datastore.v1.AggregationResultBatch.fromObject(object.batch); + } + if (object.query != null) { + if (typeof object.query !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryResponse.query: object expected"); + message.query = $root.google.datastore.v1.AggregationQuery.fromObject(object.query); + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; + if (object.explainMetrics != null) { + if (typeof object.explainMetrics !== "object") + throw TypeError(".google.datastore.v1.RunAggregationQueryResponse.explainMetrics: object expected"); + message.explainMetrics = $root.google.datastore.v1.ExplainMetrics.fromObject(object.explainMetrics); + } + return message; + }; + + /** + * Creates a plain object from a RunAggregationQueryResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {google.datastore.v1.RunAggregationQueryResponse} message RunAggregationQueryResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RunAggregationQueryResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.batch = null; + object.query = null; + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.explainMetrics = null; + } + if (message.batch != null && message.hasOwnProperty("batch")) + object.batch = $root.google.datastore.v1.AggregationResultBatch.toObject(message.batch, options); + if (message.query != null && message.hasOwnProperty("query")) + object.query = $root.google.datastore.v1.AggregationQuery.toObject(message.query, options); + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.explainMetrics != null && message.hasOwnProperty("explainMetrics")) + object.explainMetrics = $root.google.datastore.v1.ExplainMetrics.toObject(message.explainMetrics, options); + return object; + }; + + /** + * Converts this RunAggregationQueryResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @instance + * @returns {Object.} JSON object + */ + RunAggregationQueryResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RunAggregationQueryResponse + * @function getTypeUrl + * @memberof google.datastore.v1.RunAggregationQueryResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RunAggregationQueryResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.RunAggregationQueryResponse"; + }; + + return RunAggregationQueryResponse; + })(); + + v1.BeginTransactionRequest = (function() { + + /** + * Properties of a BeginTransactionRequest. + * @memberof google.datastore.v1 + * @interface IBeginTransactionRequest + * @property {string|null} [projectId] BeginTransactionRequest projectId + * @property {string|null} [databaseId] BeginTransactionRequest databaseId + * @property {google.datastore.v1.ITransactionOptions|null} [transactionOptions] BeginTransactionRequest transactionOptions + */ + + /** + * Constructs a new BeginTransactionRequest. + * @memberof google.datastore.v1 + * @classdesc Represents a BeginTransactionRequest. + * @implements IBeginTransactionRequest + * @constructor + * @param {google.datastore.v1.IBeginTransactionRequest=} [properties] Properties to set + */ + function BeginTransactionRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.projectId = ""; + + /** + * BeginTransactionRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.databaseId = ""; + + /** + * BeginTransactionRequest transactionOptions. + * @member {google.datastore.v1.ITransactionOptions|null|undefined} transactionOptions + * @memberof google.datastore.v1.BeginTransactionRequest + * @instance + */ + BeginTransactionRequest.prototype.transactionOptions = null; + + /** + * Creates a new BeginTransactionRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {google.datastore.v1.IBeginTransactionRequest=} [properties] Properties to set + * @returns {google.datastore.v1.BeginTransactionRequest} BeginTransactionRequest instance + */ + BeginTransactionRequest.create = function create(properties) { + return new BeginTransactionRequest(properties); + }; + + /** + * Encodes the specified BeginTransactionRequest message. Does not implicitly {@link google.datastore.v1.BeginTransactionRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {google.datastore.v1.IBeginTransactionRequest} message BeginTransactionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + if (message.transactionOptions != null && Object.hasOwnProperty.call(message, "transactionOptions")) + $root.google.datastore.v1.TransactionOptions.encode(message.transactionOptions, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BeginTransactionRequest message, length delimited. Does not implicitly {@link google.datastore.v1.BeginTransactionRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {google.datastore.v1.IBeginTransactionRequest} message BeginTransactionRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.BeginTransactionRequest} BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.BeginTransactionRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 10: { + message.transactionOptions = $root.google.datastore.v1.TransactionOptions.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BeginTransactionRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.BeginTransactionRequest} BeginTransactionRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BeginTransactionRequest message. + * @function verify + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BeginTransactionRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.transactionOptions != null && message.hasOwnProperty("transactionOptions")) { + var error = $root.google.datastore.v1.TransactionOptions.verify(message.transactionOptions); + if (error) + return "transactionOptions." + error; + } + return null; + }; + + /** + * Creates a BeginTransactionRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.BeginTransactionRequest} BeginTransactionRequest + */ + BeginTransactionRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.BeginTransactionRequest) + return object; + var message = new $root.google.datastore.v1.BeginTransactionRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.transactionOptions != null) { + if (typeof object.transactionOptions !== "object") + throw TypeError(".google.datastore.v1.BeginTransactionRequest.transactionOptions: object expected"); + message.transactionOptions = $root.google.datastore.v1.TransactionOptions.fromObject(object.transactionOptions); + } + return message; + }; + + /** + * Creates a plain object from a BeginTransactionRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {google.datastore.v1.BeginTransactionRequest} message BeginTransactionRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BeginTransactionRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.projectId = ""; + object.databaseId = ""; + object.transactionOptions = null; + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + if (message.transactionOptions != null && message.hasOwnProperty("transactionOptions")) + object.transactionOptions = $root.google.datastore.v1.TransactionOptions.toObject(message.transactionOptions, options); + return object; + }; + + /** + * Converts this BeginTransactionRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.BeginTransactionRequest + * @instance + * @returns {Object.} JSON object + */ + BeginTransactionRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BeginTransactionRequest + * @function getTypeUrl + * @memberof google.datastore.v1.BeginTransactionRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BeginTransactionRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.BeginTransactionRequest"; + }; + + return BeginTransactionRequest; + })(); + + v1.BeginTransactionResponse = (function() { + + /** + * Properties of a BeginTransactionResponse. + * @memberof google.datastore.v1 + * @interface IBeginTransactionResponse + * @property {Uint8Array|null} [transaction] BeginTransactionResponse transaction + */ + + /** + * Constructs a new BeginTransactionResponse. + * @memberof google.datastore.v1 + * @classdesc Represents a BeginTransactionResponse. + * @implements IBeginTransactionResponse + * @constructor + * @param {google.datastore.v1.IBeginTransactionResponse=} [properties] Properties to set + */ + function BeginTransactionResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BeginTransactionResponse transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.BeginTransactionResponse + * @instance + */ + BeginTransactionResponse.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a new BeginTransactionResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {google.datastore.v1.IBeginTransactionResponse=} [properties] Properties to set + * @returns {google.datastore.v1.BeginTransactionResponse} BeginTransactionResponse instance + */ + BeginTransactionResponse.create = function create(properties) { + return new BeginTransactionResponse(properties); + }; + + /** + * Encodes the specified BeginTransactionResponse message. Does not implicitly {@link google.datastore.v1.BeginTransactionResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {google.datastore.v1.IBeginTransactionResponse} message BeginTransactionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.transaction); + return writer; + }; + + /** + * Encodes the specified BeginTransactionResponse message, length delimited. Does not implicitly {@link google.datastore.v1.BeginTransactionResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {google.datastore.v1.IBeginTransactionResponse} message BeginTransactionResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BeginTransactionResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.BeginTransactionResponse} BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.BeginTransactionResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.transaction = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BeginTransactionResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.BeginTransactionResponse} BeginTransactionResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BeginTransactionResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BeginTransactionResponse message. + * @function verify + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BeginTransactionResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + return null; + }; + + /** + * Creates a BeginTransactionResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.BeginTransactionResponse} BeginTransactionResponse + */ + BeginTransactionResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.BeginTransactionResponse) + return object; + var message = new $root.google.datastore.v1.BeginTransactionResponse(); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a BeginTransactionResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {google.datastore.v1.BeginTransactionResponse} message BeginTransactionResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BeginTransactionResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + return object; + }; + + /** + * Converts this BeginTransactionResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.BeginTransactionResponse + * @instance + * @returns {Object.} JSON object + */ + BeginTransactionResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BeginTransactionResponse + * @function getTypeUrl + * @memberof google.datastore.v1.BeginTransactionResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BeginTransactionResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.BeginTransactionResponse"; + }; + + return BeginTransactionResponse; + })(); + + v1.RollbackRequest = (function() { + + /** + * Properties of a RollbackRequest. + * @memberof google.datastore.v1 + * @interface IRollbackRequest + * @property {string|null} [projectId] RollbackRequest projectId + * @property {string|null} [databaseId] RollbackRequest databaseId + * @property {Uint8Array|null} [transaction] RollbackRequest transaction + */ + + /** + * Constructs a new RollbackRequest. + * @memberof google.datastore.v1 + * @classdesc Represents a RollbackRequest. + * @implements IRollbackRequest + * @constructor + * @param {google.datastore.v1.IRollbackRequest=} [properties] Properties to set + */ + function RollbackRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RollbackRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.projectId = ""; + + /** + * RollbackRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.databaseId = ""; + + /** + * RollbackRequest transaction. + * @member {Uint8Array} transaction + * @memberof google.datastore.v1.RollbackRequest + * @instance + */ + RollbackRequest.prototype.transaction = $util.newBuffer([]); + + /** + * Creates a new RollbackRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {google.datastore.v1.IRollbackRequest=} [properties] Properties to set + * @returns {google.datastore.v1.RollbackRequest} RollbackRequest instance + */ + RollbackRequest.create = function create(properties) { + return new RollbackRequest(properties); + }; + + /** + * Encodes the specified RollbackRequest message. Does not implicitly {@link google.datastore.v1.RollbackRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {google.datastore.v1.IRollbackRequest} message RollbackRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.transaction); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + return writer; + }; + + /** + * Encodes the specified RollbackRequest message, length delimited. Does not implicitly {@link google.datastore.v1.RollbackRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {google.datastore.v1.IRollbackRequest} message RollbackRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.RollbackRequest} RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.RollbackRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 1: { + message.transaction = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RollbackRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.RollbackRequest} RollbackRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RollbackRequest message. + * @function verify + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RollbackRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.transaction != null && message.hasOwnProperty("transaction")) + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + return null; + }; + + /** + * Creates a RollbackRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.RollbackRequest} RollbackRequest + */ + RollbackRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.RollbackRequest) + return object; + var message = new $root.google.datastore.v1.RollbackRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; + return message; + }; + + /** + * Creates a plain object from a RollbackRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {google.datastore.v1.RollbackRequest} message RollbackRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RollbackRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if (options.bytes === String) + object.transaction = ""; + else { + object.transaction = []; + if (options.bytes !== Array) + object.transaction = $util.newBuffer(object.transaction); + } + object.projectId = ""; + object.databaseId = ""; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + return object; + }; + + /** + * Converts this RollbackRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.RollbackRequest + * @instance + * @returns {Object.} JSON object + */ + RollbackRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RollbackRequest + * @function getTypeUrl + * @memberof google.datastore.v1.RollbackRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RollbackRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.RollbackRequest"; + }; + + return RollbackRequest; + })(); + + v1.RollbackResponse = (function() { + + /** + * Properties of a RollbackResponse. + * @memberof google.datastore.v1 + * @interface IRollbackResponse + */ + + /** + * Constructs a new RollbackResponse. + * @memberof google.datastore.v1 + * @classdesc Represents a RollbackResponse. + * @implements IRollbackResponse + * @constructor + * @param {google.datastore.v1.IRollbackResponse=} [properties] Properties to set + */ + function RollbackResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new RollbackResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {google.datastore.v1.IRollbackResponse=} [properties] Properties to set + * @returns {google.datastore.v1.RollbackResponse} RollbackResponse instance + */ + RollbackResponse.create = function create(properties) { + return new RollbackResponse(properties); + }; + + /** + * Encodes the specified RollbackResponse message. Does not implicitly {@link google.datastore.v1.RollbackResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {google.datastore.v1.IRollbackResponse} message RollbackResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified RollbackResponse message, length delimited. Does not implicitly {@link google.datastore.v1.RollbackResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {google.datastore.v1.IRollbackResponse} message RollbackResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RollbackResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RollbackResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.RollbackResponse} RollbackResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.RollbackResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RollbackResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.RollbackResponse} RollbackResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RollbackResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RollbackResponse message. + * @function verify + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RollbackResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a RollbackResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.RollbackResponse} RollbackResponse + */ + RollbackResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.RollbackResponse) + return object; + return new $root.google.datastore.v1.RollbackResponse(); + }; + + /** + * Creates a plain object from a RollbackResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {google.datastore.v1.RollbackResponse} message RollbackResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RollbackResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this RollbackResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.RollbackResponse + * @instance + * @returns {Object.} JSON object + */ + RollbackResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RollbackResponse + * @function getTypeUrl + * @memberof google.datastore.v1.RollbackResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RollbackResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.RollbackResponse"; + }; + + return RollbackResponse; + })(); + + v1.CommitRequest = (function() { + + /** + * Properties of a CommitRequest. + * @memberof google.datastore.v1 + * @interface ICommitRequest + * @property {string|null} [projectId] CommitRequest projectId + * @property {string|null} [databaseId] CommitRequest databaseId + * @property {google.datastore.v1.CommitRequest.Mode|null} [mode] CommitRequest mode + * @property {Uint8Array|null} [transaction] CommitRequest transaction + * @property {google.datastore.v1.ITransactionOptions|null} [singleUseTransaction] CommitRequest singleUseTransaction + * @property {Array.|null} [mutations] CommitRequest mutations + */ + + /** + * Constructs a new CommitRequest. + * @memberof google.datastore.v1 + * @classdesc Represents a CommitRequest. + * @implements ICommitRequest + * @constructor + * @param {google.datastore.v1.ICommitRequest=} [properties] Properties to set + */ + function CommitRequest(properties) { + this.mutations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.projectId = ""; + + /** + * CommitRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.databaseId = ""; + + /** + * CommitRequest mode. + * @member {google.datastore.v1.CommitRequest.Mode} mode + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.mode = 0; + + /** + * CommitRequest transaction. + * @member {Uint8Array|null|undefined} transaction + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.transaction = null; + + /** + * CommitRequest singleUseTransaction. + * @member {google.datastore.v1.ITransactionOptions|null|undefined} singleUseTransaction + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.singleUseTransaction = null; + + /** + * CommitRequest mutations. + * @member {Array.} mutations + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + CommitRequest.prototype.mutations = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * CommitRequest transactionSelector. + * @member {"transaction"|"singleUseTransaction"|undefined} transactionSelector + * @memberof google.datastore.v1.CommitRequest + * @instance + */ + Object.defineProperty(CommitRequest.prototype, "transactionSelector", { + get: $util.oneOfGetter($oneOfFields = ["transaction", "singleUseTransaction"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new CommitRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {google.datastore.v1.ICommitRequest=} [properties] Properties to set + * @returns {google.datastore.v1.CommitRequest} CommitRequest instance + */ + CommitRequest.create = function create(properties) { + return new CommitRequest(properties); + }; + + /** + * Encodes the specified CommitRequest message. Does not implicitly {@link google.datastore.v1.CommitRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {google.datastore.v1.ICommitRequest} message CommitRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.transaction); + if (message.mode != null && Object.hasOwnProperty.call(message, "mode")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.mode); + if (message.mutations != null && message.mutations.length) + for (var i = 0; i < message.mutations.length; ++i) + $root.google.datastore.v1.Mutation.encode(message.mutations[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + if (message.singleUseTransaction != null && Object.hasOwnProperty.call(message, "singleUseTransaction")) + $root.google.datastore.v1.TransactionOptions.encode(message.singleUseTransaction, writer.uint32(/* id 10, wireType 2 =*/82).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CommitRequest message, length delimited. Does not implicitly {@link google.datastore.v1.CommitRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {google.datastore.v1.ICommitRequest} message CommitRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CommitRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.CommitRequest} CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.CommitRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 5: { + message.mode = reader.int32(); + break; + } + case 1: { + message.transaction = reader.bytes(); + break; + } + case 10: { + message.singleUseTransaction = $root.google.datastore.v1.TransactionOptions.decode(reader, reader.uint32()); + break; + } + case 6: { + if (!(message.mutations && message.mutations.length)) + message.mutations = []; + message.mutations.push($root.google.datastore.v1.Mutation.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CommitRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.CommitRequest} CommitRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CommitRequest message. + * @function verify + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CommitRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.mode != null && message.hasOwnProperty("mode")) + switch (message.mode) { + default: + return "mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + properties.transactionSelector = 1; + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + } + if (message.singleUseTransaction != null && message.hasOwnProperty("singleUseTransaction")) { + if (properties.transactionSelector === 1) + return "transactionSelector: multiple values"; + properties.transactionSelector = 1; + { + var error = $root.google.datastore.v1.TransactionOptions.verify(message.singleUseTransaction); + if (error) + return "singleUseTransaction." + error; + } + } + if (message.mutations != null && message.hasOwnProperty("mutations")) { + if (!Array.isArray(message.mutations)) + return "mutations: array expected"; + for (var i = 0; i < message.mutations.length; ++i) { + var error = $root.google.datastore.v1.Mutation.verify(message.mutations[i]); + if (error) + return "mutations." + error; + } + } + return null; + }; + + /** + * Creates a CommitRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.CommitRequest} CommitRequest + */ + CommitRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.CommitRequest) + return object; + var message = new $root.google.datastore.v1.CommitRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + switch (object.mode) { + default: + if (typeof object.mode === "number") { + message.mode = object.mode; + break; + } + break; + case "MODE_UNSPECIFIED": + case 0: + message.mode = 0; + break; + case "TRANSACTIONAL": + case 1: + message.mode = 1; + break; + case "NON_TRANSACTIONAL": + case 2: + message.mode = 2; + break; + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; + if (object.singleUseTransaction != null) { + if (typeof object.singleUseTransaction !== "object") + throw TypeError(".google.datastore.v1.CommitRequest.singleUseTransaction: object expected"); + message.singleUseTransaction = $root.google.datastore.v1.TransactionOptions.fromObject(object.singleUseTransaction); + } + if (object.mutations) { + if (!Array.isArray(object.mutations)) + throw TypeError(".google.datastore.v1.CommitRequest.mutations: array expected"); + message.mutations = []; + for (var i = 0; i < object.mutations.length; ++i) { + if (typeof object.mutations[i] !== "object") + throw TypeError(".google.datastore.v1.CommitRequest.mutations: object expected"); + message.mutations[i] = $root.google.datastore.v1.Mutation.fromObject(object.mutations[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a CommitRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {google.datastore.v1.CommitRequest} message CommitRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommitRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.mutations = []; + if (options.defaults) { + object.mode = options.enums === String ? "MODE_UNSPECIFIED" : 0; + object.projectId = ""; + object.databaseId = ""; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.transactionSelector = "transaction"; + } + if (message.mode != null && message.hasOwnProperty("mode")) + object.mode = options.enums === String ? $root.google.datastore.v1.CommitRequest.Mode[message.mode] === undefined ? message.mode : $root.google.datastore.v1.CommitRequest.Mode[message.mode] : message.mode; + if (message.mutations && message.mutations.length) { + object.mutations = []; + for (var j = 0; j < message.mutations.length; ++j) + object.mutations[j] = $root.google.datastore.v1.Mutation.toObject(message.mutations[j], options); + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + if (message.singleUseTransaction != null && message.hasOwnProperty("singleUseTransaction")) { + object.singleUseTransaction = $root.google.datastore.v1.TransactionOptions.toObject(message.singleUseTransaction, options); + if (options.oneofs) + object.transactionSelector = "singleUseTransaction"; + } + return object; + }; + + /** + * Converts this CommitRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.CommitRequest + * @instance + * @returns {Object.} JSON object + */ + CommitRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CommitRequest + * @function getTypeUrl + * @memberof google.datastore.v1.CommitRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CommitRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.CommitRequest"; + }; + + /** + * Mode enum. + * @name google.datastore.v1.CommitRequest.Mode + * @enum {number} + * @property {number} MODE_UNSPECIFIED=0 MODE_UNSPECIFIED value + * @property {number} TRANSACTIONAL=1 TRANSACTIONAL value + * @property {number} NON_TRANSACTIONAL=2 NON_TRANSACTIONAL value + */ + CommitRequest.Mode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MODE_UNSPECIFIED"] = 0; + values[valuesById[1] = "TRANSACTIONAL"] = 1; + values[valuesById[2] = "NON_TRANSACTIONAL"] = 2; + return values; + })(); + + return CommitRequest; + })(); + + v1.CommitResponse = (function() { + + /** + * Properties of a CommitResponse. + * @memberof google.datastore.v1 + * @interface ICommitResponse + * @property {Array.|null} [mutationResults] CommitResponse mutationResults + * @property {number|null} [indexUpdates] CommitResponse indexUpdates + * @property {google.protobuf.ITimestamp|null} [commitTime] CommitResponse commitTime + */ + + /** + * Constructs a new CommitResponse. + * @memberof google.datastore.v1 + * @classdesc Represents a CommitResponse. + * @implements ICommitResponse + * @constructor + * @param {google.datastore.v1.ICommitResponse=} [properties] Properties to set + */ + function CommitResponse(properties) { + this.mutationResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommitResponse mutationResults. + * @member {Array.} mutationResults + * @memberof google.datastore.v1.CommitResponse + * @instance + */ + CommitResponse.prototype.mutationResults = $util.emptyArray; + + /** + * CommitResponse indexUpdates. + * @member {number} indexUpdates + * @memberof google.datastore.v1.CommitResponse + * @instance + */ + CommitResponse.prototype.indexUpdates = 0; + + /** + * CommitResponse commitTime. + * @member {google.protobuf.ITimestamp|null|undefined} commitTime + * @memberof google.datastore.v1.CommitResponse + * @instance + */ + CommitResponse.prototype.commitTime = null; + + /** + * Creates a new CommitResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {google.datastore.v1.ICommitResponse=} [properties] Properties to set + * @returns {google.datastore.v1.CommitResponse} CommitResponse instance + */ + CommitResponse.create = function create(properties) { + return new CommitResponse(properties); + }; + + /** + * Encodes the specified CommitResponse message. Does not implicitly {@link google.datastore.v1.CommitResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {google.datastore.v1.ICommitResponse} message CommitResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.mutationResults != null && message.mutationResults.length) + for (var i = 0; i < message.mutationResults.length; ++i) + $root.google.datastore.v1.MutationResult.encode(message.mutationResults[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.indexUpdates != null && Object.hasOwnProperty.call(message, "indexUpdates")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.indexUpdates); + if (message.commitTime != null && Object.hasOwnProperty.call(message, "commitTime")) + $root.google.protobuf.Timestamp.encode(message.commitTime, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CommitResponse message, length delimited. Does not implicitly {@link google.datastore.v1.CommitResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {google.datastore.v1.ICommitResponse} message CommitResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommitResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CommitResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.CommitResponse} CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.CommitResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + if (!(message.mutationResults && message.mutationResults.length)) + message.mutationResults = []; + message.mutationResults.push($root.google.datastore.v1.MutationResult.decode(reader, reader.uint32())); + break; + } + case 4: { + message.indexUpdates = reader.int32(); + break; + } + case 8: { + message.commitTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CommitResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.CommitResponse} CommitResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommitResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CommitResponse message. + * @function verify + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CommitResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.mutationResults != null && message.hasOwnProperty("mutationResults")) { + if (!Array.isArray(message.mutationResults)) + return "mutationResults: array expected"; + for (var i = 0; i < message.mutationResults.length; ++i) { + var error = $root.google.datastore.v1.MutationResult.verify(message.mutationResults[i]); + if (error) + return "mutationResults." + error; + } + } + if (message.indexUpdates != null && message.hasOwnProperty("indexUpdates")) + if (!$util.isInteger(message.indexUpdates)) + return "indexUpdates: integer expected"; + if (message.commitTime != null && message.hasOwnProperty("commitTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.commitTime); + if (error) + return "commitTime." + error; + } + return null; + }; + + /** + * Creates a CommitResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.CommitResponse} CommitResponse + */ + CommitResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.CommitResponse) + return object; + var message = new $root.google.datastore.v1.CommitResponse(); + if (object.mutationResults) { + if (!Array.isArray(object.mutationResults)) + throw TypeError(".google.datastore.v1.CommitResponse.mutationResults: array expected"); + message.mutationResults = []; + for (var i = 0; i < object.mutationResults.length; ++i) { + if (typeof object.mutationResults[i] !== "object") + throw TypeError(".google.datastore.v1.CommitResponse.mutationResults: object expected"); + message.mutationResults[i] = $root.google.datastore.v1.MutationResult.fromObject(object.mutationResults[i]); + } + } + if (object.indexUpdates != null) + message.indexUpdates = object.indexUpdates | 0; + if (object.commitTime != null) { + if (typeof object.commitTime !== "object") + throw TypeError(".google.datastore.v1.CommitResponse.commitTime: object expected"); + message.commitTime = $root.google.protobuf.Timestamp.fromObject(object.commitTime); + } + return message; + }; + + /** + * Creates a plain object from a CommitResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {google.datastore.v1.CommitResponse} message CommitResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommitResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.mutationResults = []; + if (options.defaults) { + object.indexUpdates = 0; + object.commitTime = null; + } + if (message.mutationResults && message.mutationResults.length) { + object.mutationResults = []; + for (var j = 0; j < message.mutationResults.length; ++j) + object.mutationResults[j] = $root.google.datastore.v1.MutationResult.toObject(message.mutationResults[j], options); + } + if (message.indexUpdates != null && message.hasOwnProperty("indexUpdates")) + object.indexUpdates = message.indexUpdates; + if (message.commitTime != null && message.hasOwnProperty("commitTime")) + object.commitTime = $root.google.protobuf.Timestamp.toObject(message.commitTime, options); + return object; + }; + + /** + * Converts this CommitResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.CommitResponse + * @instance + * @returns {Object.} JSON object + */ + CommitResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CommitResponse + * @function getTypeUrl + * @memberof google.datastore.v1.CommitResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CommitResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.CommitResponse"; + }; + + return CommitResponse; + })(); + + v1.AllocateIdsRequest = (function() { + + /** + * Properties of an AllocateIdsRequest. + * @memberof google.datastore.v1 + * @interface IAllocateIdsRequest + * @property {string|null} [projectId] AllocateIdsRequest projectId + * @property {string|null} [databaseId] AllocateIdsRequest databaseId + * @property {Array.|null} [keys] AllocateIdsRequest keys + */ + + /** + * Constructs a new AllocateIdsRequest. + * @memberof google.datastore.v1 + * @classdesc Represents an AllocateIdsRequest. + * @implements IAllocateIdsRequest + * @constructor + * @param {google.datastore.v1.IAllocateIdsRequest=} [properties] Properties to set + */ + function AllocateIdsRequest(properties) { + this.keys = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * AllocateIdsRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.AllocateIdsRequest + * @instance + */ + AllocateIdsRequest.prototype.projectId = ""; + + /** + * AllocateIdsRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.AllocateIdsRequest + * @instance + */ + AllocateIdsRequest.prototype.databaseId = ""; + + /** + * AllocateIdsRequest keys. + * @member {Array.} keys + * @memberof google.datastore.v1.AllocateIdsRequest + * @instance + */ + AllocateIdsRequest.prototype.keys = $util.emptyArray; + + /** + * Creates a new AllocateIdsRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {google.datastore.v1.IAllocateIdsRequest=} [properties] Properties to set + * @returns {google.datastore.v1.AllocateIdsRequest} AllocateIdsRequest instance + */ + AllocateIdsRequest.create = function create(properties) { + return new AllocateIdsRequest(properties); + }; + + /** + * Encodes the specified AllocateIdsRequest message. Does not implicitly {@link google.datastore.v1.AllocateIdsRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {google.datastore.v1.IAllocateIdsRequest} message AllocateIdsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AllocateIdsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.keys != null && message.keys.length) + for (var i = 0; i < message.keys.length; ++i) + $root.google.datastore.v1.Key.encode(message.keys[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + return writer; + }; + + /** + * Encodes the specified AllocateIdsRequest message, length delimited. Does not implicitly {@link google.datastore.v1.AllocateIdsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {google.datastore.v1.IAllocateIdsRequest} message AllocateIdsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AllocateIdsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AllocateIdsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AllocateIdsRequest} AllocateIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AllocateIdsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AllocateIdsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 1: { + if (!(message.keys && message.keys.length)) + message.keys = []; + message.keys.push($root.google.datastore.v1.Key.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AllocateIdsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AllocateIdsRequest} AllocateIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AllocateIdsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AllocateIdsRequest message. + * @function verify + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AllocateIdsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.keys != null && message.hasOwnProperty("keys")) { + if (!Array.isArray(message.keys)) + return "keys: array expected"; + for (var i = 0; i < message.keys.length; ++i) { + var error = $root.google.datastore.v1.Key.verify(message.keys[i]); + if (error) + return "keys." + error; + } + } + return null; + }; + + /** + * Creates an AllocateIdsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AllocateIdsRequest} AllocateIdsRequest + */ + AllocateIdsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AllocateIdsRequest) + return object; + var message = new $root.google.datastore.v1.AllocateIdsRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.keys) { + if (!Array.isArray(object.keys)) + throw TypeError(".google.datastore.v1.AllocateIdsRequest.keys: array expected"); + message.keys = []; + for (var i = 0; i < object.keys.length; ++i) { + if (typeof object.keys[i] !== "object") + throw TypeError(".google.datastore.v1.AllocateIdsRequest.keys: object expected"); + message.keys[i] = $root.google.datastore.v1.Key.fromObject(object.keys[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an AllocateIdsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {google.datastore.v1.AllocateIdsRequest} message AllocateIdsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AllocateIdsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.keys = []; + if (options.defaults) { + object.projectId = ""; + object.databaseId = ""; + } + if (message.keys && message.keys.length) { + object.keys = []; + for (var j = 0; j < message.keys.length; ++j) + object.keys[j] = $root.google.datastore.v1.Key.toObject(message.keys[j], options); + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + return object; + }; + + /** + * Converts this AllocateIdsRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.AllocateIdsRequest + * @instance + * @returns {Object.} JSON object + */ + AllocateIdsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AllocateIdsRequest + * @function getTypeUrl + * @memberof google.datastore.v1.AllocateIdsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AllocateIdsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AllocateIdsRequest"; + }; + + return AllocateIdsRequest; + })(); + + v1.AllocateIdsResponse = (function() { + + /** + * Properties of an AllocateIdsResponse. + * @memberof google.datastore.v1 + * @interface IAllocateIdsResponse + * @property {Array.|null} [keys] AllocateIdsResponse keys + */ + + /** + * Constructs a new AllocateIdsResponse. + * @memberof google.datastore.v1 + * @classdesc Represents an AllocateIdsResponse. + * @implements IAllocateIdsResponse + * @constructor + * @param {google.datastore.v1.IAllocateIdsResponse=} [properties] Properties to set + */ + function AllocateIdsResponse(properties) { + this.keys = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * AllocateIdsResponse keys. + * @member {Array.} keys + * @memberof google.datastore.v1.AllocateIdsResponse + * @instance + */ + AllocateIdsResponse.prototype.keys = $util.emptyArray; + + /** + * Creates a new AllocateIdsResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {google.datastore.v1.IAllocateIdsResponse=} [properties] Properties to set + * @returns {google.datastore.v1.AllocateIdsResponse} AllocateIdsResponse instance + */ + AllocateIdsResponse.create = function create(properties) { + return new AllocateIdsResponse(properties); + }; + + /** + * Encodes the specified AllocateIdsResponse message. Does not implicitly {@link google.datastore.v1.AllocateIdsResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {google.datastore.v1.IAllocateIdsResponse} message AllocateIdsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AllocateIdsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.keys != null && message.keys.length) + for (var i = 0; i < message.keys.length; ++i) + $root.google.datastore.v1.Key.encode(message.keys[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified AllocateIdsResponse message, length delimited. Does not implicitly {@link google.datastore.v1.AllocateIdsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {google.datastore.v1.IAllocateIdsResponse} message AllocateIdsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + AllocateIdsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an AllocateIdsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.AllocateIdsResponse} AllocateIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AllocateIdsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.AllocateIdsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.keys && message.keys.length)) + message.keys = []; + message.keys.push($root.google.datastore.v1.Key.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an AllocateIdsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.AllocateIdsResponse} AllocateIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + AllocateIdsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an AllocateIdsResponse message. + * @function verify + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + AllocateIdsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.keys != null && message.hasOwnProperty("keys")) { + if (!Array.isArray(message.keys)) + return "keys: array expected"; + for (var i = 0; i < message.keys.length; ++i) { + var error = $root.google.datastore.v1.Key.verify(message.keys[i]); + if (error) + return "keys." + error; + } + } + return null; + }; + + /** + * Creates an AllocateIdsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.AllocateIdsResponse} AllocateIdsResponse + */ + AllocateIdsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.AllocateIdsResponse) + return object; + var message = new $root.google.datastore.v1.AllocateIdsResponse(); + if (object.keys) { + if (!Array.isArray(object.keys)) + throw TypeError(".google.datastore.v1.AllocateIdsResponse.keys: array expected"); + message.keys = []; + for (var i = 0; i < object.keys.length; ++i) { + if (typeof object.keys[i] !== "object") + throw TypeError(".google.datastore.v1.AllocateIdsResponse.keys: object expected"); + message.keys[i] = $root.google.datastore.v1.Key.fromObject(object.keys[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an AllocateIdsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {google.datastore.v1.AllocateIdsResponse} message AllocateIdsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + AllocateIdsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.keys = []; + if (message.keys && message.keys.length) { + object.keys = []; + for (var j = 0; j < message.keys.length; ++j) + object.keys[j] = $root.google.datastore.v1.Key.toObject(message.keys[j], options); + } + return object; + }; + + /** + * Converts this AllocateIdsResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.AllocateIdsResponse + * @instance + * @returns {Object.} JSON object + */ + AllocateIdsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for AllocateIdsResponse + * @function getTypeUrl + * @memberof google.datastore.v1.AllocateIdsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + AllocateIdsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.AllocateIdsResponse"; + }; + + return AllocateIdsResponse; + })(); + + v1.ReserveIdsRequest = (function() { + + /** + * Properties of a ReserveIdsRequest. + * @memberof google.datastore.v1 + * @interface IReserveIdsRequest + * @property {string|null} [projectId] ReserveIdsRequest projectId + * @property {string|null} [databaseId] ReserveIdsRequest databaseId + * @property {Array.|null} [keys] ReserveIdsRequest keys + */ + + /** + * Constructs a new ReserveIdsRequest. + * @memberof google.datastore.v1 + * @classdesc Represents a ReserveIdsRequest. + * @implements IReserveIdsRequest + * @constructor + * @param {google.datastore.v1.IReserveIdsRequest=} [properties] Properties to set + */ + function ReserveIdsRequest(properties) { + this.keys = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReserveIdsRequest projectId. + * @member {string} projectId + * @memberof google.datastore.v1.ReserveIdsRequest + * @instance + */ + ReserveIdsRequest.prototype.projectId = ""; + + /** + * ReserveIdsRequest databaseId. + * @member {string} databaseId + * @memberof google.datastore.v1.ReserveIdsRequest + * @instance + */ + ReserveIdsRequest.prototype.databaseId = ""; + + /** + * ReserveIdsRequest keys. + * @member {Array.} keys + * @memberof google.datastore.v1.ReserveIdsRequest + * @instance + */ + ReserveIdsRequest.prototype.keys = $util.emptyArray; + + /** + * Creates a new ReserveIdsRequest instance using the specified properties. + * @function create + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {google.datastore.v1.IReserveIdsRequest=} [properties] Properties to set + * @returns {google.datastore.v1.ReserveIdsRequest} ReserveIdsRequest instance + */ + ReserveIdsRequest.create = function create(properties) { + return new ReserveIdsRequest(properties); + }; + + /** + * Encodes the specified ReserveIdsRequest message. Does not implicitly {@link google.datastore.v1.ReserveIdsRequest.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {google.datastore.v1.IReserveIdsRequest} message ReserveIdsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReserveIdsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.keys != null && message.keys.length) + for (var i = 0; i < message.keys.length; ++i) + $root.google.datastore.v1.Key.encode(message.keys[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.projectId); + if (message.databaseId != null && Object.hasOwnProperty.call(message, "databaseId")) + writer.uint32(/* id 9, wireType 2 =*/74).string(message.databaseId); + return writer; + }; + + /** + * Encodes the specified ReserveIdsRequest message, length delimited. Does not implicitly {@link google.datastore.v1.ReserveIdsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {google.datastore.v1.IReserveIdsRequest} message ReserveIdsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReserveIdsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReserveIdsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.ReserveIdsRequest} ReserveIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReserveIdsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.ReserveIdsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 8: { + message.projectId = reader.string(); + break; + } + case 9: { + message.databaseId = reader.string(); + break; + } + case 1: { + if (!(message.keys && message.keys.length)) + message.keys = []; + message.keys.push($root.google.datastore.v1.Key.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReserveIdsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.ReserveIdsRequest} ReserveIdsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReserveIdsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReserveIdsRequest message. + * @function verify + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReserveIdsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.projectId != null && message.hasOwnProperty("projectId")) + if (!$util.isString(message.projectId)) + return "projectId: string expected"; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + if (!$util.isString(message.databaseId)) + return "databaseId: string expected"; + if (message.keys != null && message.hasOwnProperty("keys")) { + if (!Array.isArray(message.keys)) + return "keys: array expected"; + for (var i = 0; i < message.keys.length; ++i) { + var error = $root.google.datastore.v1.Key.verify(message.keys[i]); + if (error) + return "keys." + error; + } + } + return null; + }; + + /** + * Creates a ReserveIdsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.ReserveIdsRequest} ReserveIdsRequest + */ + ReserveIdsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.ReserveIdsRequest) + return object; + var message = new $root.google.datastore.v1.ReserveIdsRequest(); + if (object.projectId != null) + message.projectId = String(object.projectId); + if (object.databaseId != null) + message.databaseId = String(object.databaseId); + if (object.keys) { + if (!Array.isArray(object.keys)) + throw TypeError(".google.datastore.v1.ReserveIdsRequest.keys: array expected"); + message.keys = []; + for (var i = 0; i < object.keys.length; ++i) { + if (typeof object.keys[i] !== "object") + throw TypeError(".google.datastore.v1.ReserveIdsRequest.keys: object expected"); + message.keys[i] = $root.google.datastore.v1.Key.fromObject(object.keys[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ReserveIdsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {google.datastore.v1.ReserveIdsRequest} message ReserveIdsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReserveIdsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.keys = []; + if (options.defaults) { + object.projectId = ""; + object.databaseId = ""; + } + if (message.keys && message.keys.length) { + object.keys = []; + for (var j = 0; j < message.keys.length; ++j) + object.keys[j] = $root.google.datastore.v1.Key.toObject(message.keys[j], options); + } + if (message.projectId != null && message.hasOwnProperty("projectId")) + object.projectId = message.projectId; + if (message.databaseId != null && message.hasOwnProperty("databaseId")) + object.databaseId = message.databaseId; + return object; + }; + + /** + * Converts this ReserveIdsRequest to JSON. + * @function toJSON + * @memberof google.datastore.v1.ReserveIdsRequest + * @instance + * @returns {Object.} JSON object + */ + ReserveIdsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReserveIdsRequest + * @function getTypeUrl + * @memberof google.datastore.v1.ReserveIdsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReserveIdsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.ReserveIdsRequest"; + }; + + return ReserveIdsRequest; + })(); + + v1.ReserveIdsResponse = (function() { + + /** + * Properties of a ReserveIdsResponse. + * @memberof google.datastore.v1 + * @interface IReserveIdsResponse + */ + + /** + * Constructs a new ReserveIdsResponse. + * @memberof google.datastore.v1 + * @classdesc Represents a ReserveIdsResponse. + * @implements IReserveIdsResponse + * @constructor + * @param {google.datastore.v1.IReserveIdsResponse=} [properties] Properties to set + */ + function ReserveIdsResponse(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new ReserveIdsResponse instance using the specified properties. + * @function create + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {google.datastore.v1.IReserveIdsResponse=} [properties] Properties to set + * @returns {google.datastore.v1.ReserveIdsResponse} ReserveIdsResponse instance + */ + ReserveIdsResponse.create = function create(properties) { + return new ReserveIdsResponse(properties); + }; + + /** + * Encodes the specified ReserveIdsResponse message. Does not implicitly {@link google.datastore.v1.ReserveIdsResponse.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {google.datastore.v1.IReserveIdsResponse} message ReserveIdsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReserveIdsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified ReserveIdsResponse message, length delimited. Does not implicitly {@link google.datastore.v1.ReserveIdsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {google.datastore.v1.IReserveIdsResponse} message ReserveIdsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReserveIdsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReserveIdsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.ReserveIdsResponse} ReserveIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReserveIdsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.ReserveIdsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReserveIdsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.ReserveIdsResponse} ReserveIdsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReserveIdsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReserveIdsResponse message. + * @function verify + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReserveIdsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a ReserveIdsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.ReserveIdsResponse} ReserveIdsResponse + */ + ReserveIdsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.ReserveIdsResponse) + return object; + return new $root.google.datastore.v1.ReserveIdsResponse(); + }; + + /** + * Creates a plain object from a ReserveIdsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {google.datastore.v1.ReserveIdsResponse} message ReserveIdsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReserveIdsResponse.toObject = function toObject() { + return {}; + }; + + /** + * Converts this ReserveIdsResponse to JSON. + * @function toJSON + * @memberof google.datastore.v1.ReserveIdsResponse + * @instance + * @returns {Object.} JSON object + */ + ReserveIdsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReserveIdsResponse + * @function getTypeUrl + * @memberof google.datastore.v1.ReserveIdsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReserveIdsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.ReserveIdsResponse"; + }; + + return ReserveIdsResponse; + })(); + + v1.Mutation = (function() { + + /** + * Properties of a Mutation. + * @memberof google.datastore.v1 + * @interface IMutation + * @property {google.datastore.v1.IEntity|null} [insert] Mutation insert + * @property {google.datastore.v1.IEntity|null} [update] Mutation update + * @property {google.datastore.v1.IEntity|null} [upsert] Mutation upsert + * @property {google.datastore.v1.IKey|null} ["delete"] Mutation delete + * @property {number|Long|null} [baseVersion] Mutation baseVersion + * @property {google.protobuf.ITimestamp|null} [updateTime] Mutation updateTime + * @property {google.datastore.v1.Mutation.ConflictResolutionStrategy|null} [conflictResolutionStrategy] Mutation conflictResolutionStrategy + * @property {google.datastore.v1.IPropertyMask|null} [propertyMask] Mutation propertyMask + * @property {Array.|null} [propertyTransforms] Mutation propertyTransforms + */ + + /** + * Constructs a new Mutation. + * @memberof google.datastore.v1 + * @classdesc Represents a Mutation. + * @implements IMutation + * @constructor + * @param {google.datastore.v1.IMutation=} [properties] Properties to set + */ + function Mutation(properties) { + this.propertyTransforms = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Mutation insert. + * @member {google.datastore.v1.IEntity|null|undefined} insert + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.insert = null; + + /** + * Mutation update. + * @member {google.datastore.v1.IEntity|null|undefined} update + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.update = null; + + /** + * Mutation upsert. + * @member {google.datastore.v1.IEntity|null|undefined} upsert + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.upsert = null; + + /** + * Mutation delete. + * @member {google.datastore.v1.IKey|null|undefined} delete + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype["delete"] = null; + + /** + * Mutation baseVersion. + * @member {number|Long|null|undefined} baseVersion + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.baseVersion = null; + + /** + * Mutation updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.updateTime = null; + + /** + * Mutation conflictResolutionStrategy. + * @member {google.datastore.v1.Mutation.ConflictResolutionStrategy} conflictResolutionStrategy + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.conflictResolutionStrategy = 0; + + /** + * Mutation propertyMask. + * @member {google.datastore.v1.IPropertyMask|null|undefined} propertyMask + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.propertyMask = null; + + /** + * Mutation propertyTransforms. + * @member {Array.} propertyTransforms + * @memberof google.datastore.v1.Mutation + * @instance + */ + Mutation.prototype.propertyTransforms = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Mutation operation. + * @member {"insert"|"update"|"upsert"|"delete"|undefined} operation + * @memberof google.datastore.v1.Mutation + * @instance + */ + Object.defineProperty(Mutation.prototype, "operation", { + get: $util.oneOfGetter($oneOfFields = ["insert", "update", "upsert", "delete"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Mutation conflictDetectionStrategy. + * @member {"baseVersion"|"updateTime"|undefined} conflictDetectionStrategy + * @memberof google.datastore.v1.Mutation + * @instance + */ + Object.defineProperty(Mutation.prototype, "conflictDetectionStrategy", { + get: $util.oneOfGetter($oneOfFields = ["baseVersion", "updateTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Mutation instance using the specified properties. + * @function create + * @memberof google.datastore.v1.Mutation + * @static + * @param {google.datastore.v1.IMutation=} [properties] Properties to set + * @returns {google.datastore.v1.Mutation} Mutation instance + */ + Mutation.create = function create(properties) { + return new Mutation(properties); + }; + + /** + * Encodes the specified Mutation message. Does not implicitly {@link google.datastore.v1.Mutation.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.Mutation + * @static + * @param {google.datastore.v1.IMutation} message Mutation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Mutation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.insert != null && Object.hasOwnProperty.call(message, "insert")) + $root.google.datastore.v1.Entity.encode(message.insert, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.update != null && Object.hasOwnProperty.call(message, "update")) + $root.google.datastore.v1.Entity.encode(message.update, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.upsert != null && Object.hasOwnProperty.call(message, "upsert")) + $root.google.datastore.v1.Entity.encode(message.upsert, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message["delete"] != null && Object.hasOwnProperty.call(message, "delete")) + $root.google.datastore.v1.Key.encode(message["delete"], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.baseVersion != null && Object.hasOwnProperty.call(message, "baseVersion")) + writer.uint32(/* id 8, wireType 0 =*/64).int64(message.baseVersion); + if (message.propertyMask != null && Object.hasOwnProperty.call(message, "propertyMask")) + $root.google.datastore.v1.PropertyMask.encode(message.propertyMask, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.conflictResolutionStrategy != null && Object.hasOwnProperty.call(message, "conflictResolutionStrategy")) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.conflictResolutionStrategy); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.propertyTransforms != null && message.propertyTransforms.length) + for (var i = 0; i < message.propertyTransforms.length; ++i) + $root.google.datastore.v1.PropertyTransform.encode(message.propertyTransforms[i], writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Mutation message, length delimited. Does not implicitly {@link google.datastore.v1.Mutation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.Mutation + * @static + * @param {google.datastore.v1.IMutation} message Mutation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Mutation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Mutation message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.Mutation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.Mutation} Mutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Mutation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.Mutation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 4: { + message.insert = $root.google.datastore.v1.Entity.decode(reader, reader.uint32()); + break; + } + case 5: { + message.update = $root.google.datastore.v1.Entity.decode(reader, reader.uint32()); + break; + } + case 6: { + message.upsert = $root.google.datastore.v1.Entity.decode(reader, reader.uint32()); + break; + } + case 7: { + message["delete"] = $root.google.datastore.v1.Key.decode(reader, reader.uint32()); + break; + } + case 8: { + message.baseVersion = reader.int64(); + break; + } + case 11: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 10: { + message.conflictResolutionStrategy = reader.int32(); + break; + } + case 9: { + message.propertyMask = $root.google.datastore.v1.PropertyMask.decode(reader, reader.uint32()); + break; + } + case 12: { + if (!(message.propertyTransforms && message.propertyTransforms.length)) + message.propertyTransforms = []; + message.propertyTransforms.push($root.google.datastore.v1.PropertyTransform.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Mutation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.Mutation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.Mutation} Mutation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Mutation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Mutation message. + * @function verify + * @memberof google.datastore.v1.Mutation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Mutation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.insert != null && message.hasOwnProperty("insert")) { + properties.operation = 1; + { + var error = $root.google.datastore.v1.Entity.verify(message.insert); + if (error) + return "insert." + error; + } + } + if (message.update != null && message.hasOwnProperty("update")) { + if (properties.operation === 1) + return "operation: multiple values"; + properties.operation = 1; + { + var error = $root.google.datastore.v1.Entity.verify(message.update); + if (error) + return "update." + error; + } + } + if (message.upsert != null && message.hasOwnProperty("upsert")) { + if (properties.operation === 1) + return "operation: multiple values"; + properties.operation = 1; + { + var error = $root.google.datastore.v1.Entity.verify(message.upsert); + if (error) + return "upsert." + error; + } + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + if (properties.operation === 1) + return "operation: multiple values"; + properties.operation = 1; + { + var error = $root.google.datastore.v1.Key.verify(message["delete"]); + if (error) + return "delete." + error; + } + } + if (message.baseVersion != null && message.hasOwnProperty("baseVersion")) { + properties.conflictDetectionStrategy = 1; + if (!$util.isInteger(message.baseVersion) && !(message.baseVersion && $util.isInteger(message.baseVersion.low) && $util.isInteger(message.baseVersion.high))) + return "baseVersion: integer|Long expected"; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + if (properties.conflictDetectionStrategy === 1) + return "conflictDetectionStrategy: multiple values"; + properties.conflictDetectionStrategy = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + } + if (message.conflictResolutionStrategy != null && message.hasOwnProperty("conflictResolutionStrategy")) + switch (message.conflictResolutionStrategy) { + default: + return "conflictResolutionStrategy: enum value expected"; + case 0: + case 1: + case 3: + break; + } + if (message.propertyMask != null && message.hasOwnProperty("propertyMask")) { + var error = $root.google.datastore.v1.PropertyMask.verify(message.propertyMask); + if (error) + return "propertyMask." + error; + } + if (message.propertyTransforms != null && message.hasOwnProperty("propertyTransforms")) { + if (!Array.isArray(message.propertyTransforms)) + return "propertyTransforms: array expected"; + for (var i = 0; i < message.propertyTransforms.length; ++i) { + var error = $root.google.datastore.v1.PropertyTransform.verify(message.propertyTransforms[i]); + if (error) + return "propertyTransforms." + error; + } + } + return null; + }; + + /** + * Creates a Mutation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.Mutation + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.Mutation} Mutation + */ + Mutation.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.Mutation) + return object; + var message = new $root.google.datastore.v1.Mutation(); + if (object.insert != null) { + if (typeof object.insert !== "object") + throw TypeError(".google.datastore.v1.Mutation.insert: object expected"); + message.insert = $root.google.datastore.v1.Entity.fromObject(object.insert); + } + if (object.update != null) { + if (typeof object.update !== "object") + throw TypeError(".google.datastore.v1.Mutation.update: object expected"); + message.update = $root.google.datastore.v1.Entity.fromObject(object.update); + } + if (object.upsert != null) { + if (typeof object.upsert !== "object") + throw TypeError(".google.datastore.v1.Mutation.upsert: object expected"); + message.upsert = $root.google.datastore.v1.Entity.fromObject(object.upsert); + } + if (object["delete"] != null) { + if (typeof object["delete"] !== "object") + throw TypeError(".google.datastore.v1.Mutation.delete: object expected"); + message["delete"] = $root.google.datastore.v1.Key.fromObject(object["delete"]); + } + if (object.baseVersion != null) + if ($util.Long) + (message.baseVersion = $util.Long.fromValue(object.baseVersion)).unsigned = false; + else if (typeof object.baseVersion === "string") + message.baseVersion = parseInt(object.baseVersion, 10); + else if (typeof object.baseVersion === "number") + message.baseVersion = object.baseVersion; + else if (typeof object.baseVersion === "object") + message.baseVersion = new $util.LongBits(object.baseVersion.low >>> 0, object.baseVersion.high >>> 0).toNumber(); + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.datastore.v1.Mutation.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + switch (object.conflictResolutionStrategy) { + default: + if (typeof object.conflictResolutionStrategy === "number") { + message.conflictResolutionStrategy = object.conflictResolutionStrategy; + break; + } + break; + case "STRATEGY_UNSPECIFIED": + case 0: + message.conflictResolutionStrategy = 0; + break; + case "SERVER_VALUE": + case 1: + message.conflictResolutionStrategy = 1; + break; + case "FAIL": + case 3: + message.conflictResolutionStrategy = 3; + break; + } + if (object.propertyMask != null) { + if (typeof object.propertyMask !== "object") + throw TypeError(".google.datastore.v1.Mutation.propertyMask: object expected"); + message.propertyMask = $root.google.datastore.v1.PropertyMask.fromObject(object.propertyMask); + } + if (object.propertyTransforms) { + if (!Array.isArray(object.propertyTransforms)) + throw TypeError(".google.datastore.v1.Mutation.propertyTransforms: array expected"); + message.propertyTransforms = []; + for (var i = 0; i < object.propertyTransforms.length; ++i) { + if (typeof object.propertyTransforms[i] !== "object") + throw TypeError(".google.datastore.v1.Mutation.propertyTransforms: object expected"); + message.propertyTransforms[i] = $root.google.datastore.v1.PropertyTransform.fromObject(object.propertyTransforms[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Mutation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.Mutation + * @static + * @param {google.datastore.v1.Mutation} message Mutation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Mutation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.propertyTransforms = []; + if (options.defaults) { + object.propertyMask = null; + object.conflictResolutionStrategy = options.enums === String ? "STRATEGY_UNSPECIFIED" : 0; + } + if (message.insert != null && message.hasOwnProperty("insert")) { + object.insert = $root.google.datastore.v1.Entity.toObject(message.insert, options); + if (options.oneofs) + object.operation = "insert"; + } + if (message.update != null && message.hasOwnProperty("update")) { + object.update = $root.google.datastore.v1.Entity.toObject(message.update, options); + if (options.oneofs) + object.operation = "update"; + } + if (message.upsert != null && message.hasOwnProperty("upsert")) { + object.upsert = $root.google.datastore.v1.Entity.toObject(message.upsert, options); + if (options.oneofs) + object.operation = "upsert"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + object["delete"] = $root.google.datastore.v1.Key.toObject(message["delete"], options); + if (options.oneofs) + object.operation = "delete"; + } + if (message.baseVersion != null && message.hasOwnProperty("baseVersion")) { + if (typeof message.baseVersion === "number") + object.baseVersion = options.longs === String ? String(message.baseVersion) : message.baseVersion; + else + object.baseVersion = options.longs === String ? $util.Long.prototype.toString.call(message.baseVersion) : options.longs === Number ? new $util.LongBits(message.baseVersion.low >>> 0, message.baseVersion.high >>> 0).toNumber() : message.baseVersion; + if (options.oneofs) + object.conflictDetectionStrategy = "baseVersion"; + } + if (message.propertyMask != null && message.hasOwnProperty("propertyMask")) + object.propertyMask = $root.google.datastore.v1.PropertyMask.toObject(message.propertyMask, options); + if (message.conflictResolutionStrategy != null && message.hasOwnProperty("conflictResolutionStrategy")) + object.conflictResolutionStrategy = options.enums === String ? $root.google.datastore.v1.Mutation.ConflictResolutionStrategy[message.conflictResolutionStrategy] === undefined ? message.conflictResolutionStrategy : $root.google.datastore.v1.Mutation.ConflictResolutionStrategy[message.conflictResolutionStrategy] : message.conflictResolutionStrategy; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (options.oneofs) + object.conflictDetectionStrategy = "updateTime"; + } + if (message.propertyTransforms && message.propertyTransforms.length) { + object.propertyTransforms = []; + for (var j = 0; j < message.propertyTransforms.length; ++j) + object.propertyTransforms[j] = $root.google.datastore.v1.PropertyTransform.toObject(message.propertyTransforms[j], options); + } + return object; + }; + + /** + * Converts this Mutation to JSON. + * @function toJSON + * @memberof google.datastore.v1.Mutation + * @instance + * @returns {Object.} JSON object + */ + Mutation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Mutation + * @function getTypeUrl + * @memberof google.datastore.v1.Mutation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Mutation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.Mutation"; + }; + + /** + * ConflictResolutionStrategy enum. + * @name google.datastore.v1.Mutation.ConflictResolutionStrategy + * @enum {number} + * @property {number} STRATEGY_UNSPECIFIED=0 STRATEGY_UNSPECIFIED value + * @property {number} SERVER_VALUE=1 SERVER_VALUE value + * @property {number} FAIL=3 FAIL value + */ + Mutation.ConflictResolutionStrategy = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRATEGY_UNSPECIFIED"] = 0; + values[valuesById[1] = "SERVER_VALUE"] = 1; + values[valuesById[3] = "FAIL"] = 3; + return values; + })(); + + return Mutation; + })(); + + v1.PropertyTransform = (function() { + + /** + * Properties of a PropertyTransform. + * @memberof google.datastore.v1 + * @interface IPropertyTransform + * @property {string|null} [property] PropertyTransform property + * @property {google.datastore.v1.PropertyTransform.ServerValue|null} [setToServerValue] PropertyTransform setToServerValue + * @property {google.datastore.v1.IValue|null} [increment] PropertyTransform increment + * @property {google.datastore.v1.IValue|null} [maximum] PropertyTransform maximum + * @property {google.datastore.v1.IValue|null} [minimum] PropertyTransform minimum + * @property {google.datastore.v1.IArrayValue|null} [appendMissingElements] PropertyTransform appendMissingElements + * @property {google.datastore.v1.IArrayValue|null} [removeAllFromArray] PropertyTransform removeAllFromArray + */ + + /** + * Constructs a new PropertyTransform. + * @memberof google.datastore.v1 + * @classdesc Represents a PropertyTransform. + * @implements IPropertyTransform + * @constructor + * @param {google.datastore.v1.IPropertyTransform=} [properties] Properties to set + */ + function PropertyTransform(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PropertyTransform property. + * @member {string} property + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + PropertyTransform.prototype.property = ""; + + /** + * PropertyTransform setToServerValue. + * @member {google.datastore.v1.PropertyTransform.ServerValue|null|undefined} setToServerValue + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + PropertyTransform.prototype.setToServerValue = null; + + /** + * PropertyTransform increment. + * @member {google.datastore.v1.IValue|null|undefined} increment + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + PropertyTransform.prototype.increment = null; + + /** + * PropertyTransform maximum. + * @member {google.datastore.v1.IValue|null|undefined} maximum + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + PropertyTransform.prototype.maximum = null; + + /** + * PropertyTransform minimum. + * @member {google.datastore.v1.IValue|null|undefined} minimum + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + PropertyTransform.prototype.minimum = null; + + /** + * PropertyTransform appendMissingElements. + * @member {google.datastore.v1.IArrayValue|null|undefined} appendMissingElements + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + PropertyTransform.prototype.appendMissingElements = null; + + /** + * PropertyTransform removeAllFromArray. + * @member {google.datastore.v1.IArrayValue|null|undefined} removeAllFromArray + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + PropertyTransform.prototype.removeAllFromArray = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * PropertyTransform transformType. + * @member {"setToServerValue"|"increment"|"maximum"|"minimum"|"appendMissingElements"|"removeAllFromArray"|undefined} transformType + * @memberof google.datastore.v1.PropertyTransform + * @instance + */ + Object.defineProperty(PropertyTransform.prototype, "transformType", { + get: $util.oneOfGetter($oneOfFields = ["setToServerValue", "increment", "maximum", "minimum", "appendMissingElements", "removeAllFromArray"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new PropertyTransform instance using the specified properties. + * @function create + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {google.datastore.v1.IPropertyTransform=} [properties] Properties to set + * @returns {google.datastore.v1.PropertyTransform} PropertyTransform instance + */ + PropertyTransform.create = function create(properties) { + return new PropertyTransform(properties); + }; + + /** + * Encodes the specified PropertyTransform message. Does not implicitly {@link google.datastore.v1.PropertyTransform.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {google.datastore.v1.IPropertyTransform} message PropertyTransform message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyTransform.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.property != null && Object.hasOwnProperty.call(message, "property")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.property); + if (message.setToServerValue != null && Object.hasOwnProperty.call(message, "setToServerValue")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.setToServerValue); + if (message.increment != null && Object.hasOwnProperty.call(message, "increment")) + $root.google.datastore.v1.Value.encode(message.increment, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.maximum != null && Object.hasOwnProperty.call(message, "maximum")) + $root.google.datastore.v1.Value.encode(message.maximum, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.minimum != null && Object.hasOwnProperty.call(message, "minimum")) + $root.google.datastore.v1.Value.encode(message.minimum, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.appendMissingElements != null && Object.hasOwnProperty.call(message, "appendMissingElements")) + $root.google.datastore.v1.ArrayValue.encode(message.appendMissingElements, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.removeAllFromArray != null && Object.hasOwnProperty.call(message, "removeAllFromArray")) + $root.google.datastore.v1.ArrayValue.encode(message.removeAllFromArray, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PropertyTransform message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyTransform.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {google.datastore.v1.IPropertyTransform} message PropertyTransform message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyTransform.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PropertyTransform message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.PropertyTransform} PropertyTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyTransform.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.PropertyTransform(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.property = reader.string(); + break; + } + case 2: { + message.setToServerValue = reader.int32(); + break; + } + case 3: { + message.increment = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + } + case 4: { + message.maximum = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + } + case 5: { + message.minimum = $root.google.datastore.v1.Value.decode(reader, reader.uint32()); + break; + } + case 6: { + message.appendMissingElements = $root.google.datastore.v1.ArrayValue.decode(reader, reader.uint32()); + break; + } + case 7: { + message.removeAllFromArray = $root.google.datastore.v1.ArrayValue.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PropertyTransform message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.PropertyTransform} PropertyTransform + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyTransform.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PropertyTransform message. + * @function verify + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PropertyTransform.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.property != null && message.hasOwnProperty("property")) + if (!$util.isString(message.property)) + return "property: string expected"; + if (message.setToServerValue != null && message.hasOwnProperty("setToServerValue")) { + properties.transformType = 1; + switch (message.setToServerValue) { + default: + return "setToServerValue: enum value expected"; + case 0: + case 1: + break; + } + } + if (message.increment != null && message.hasOwnProperty("increment")) { + if (properties.transformType === 1) + return "transformType: multiple values"; + properties.transformType = 1; + { + var error = $root.google.datastore.v1.Value.verify(message.increment); + if (error) + return "increment." + error; + } + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + if (properties.transformType === 1) + return "transformType: multiple values"; + properties.transformType = 1; + { + var error = $root.google.datastore.v1.Value.verify(message.maximum); + if (error) + return "maximum." + error; + } + } + if (message.minimum != null && message.hasOwnProperty("minimum")) { + if (properties.transformType === 1) + return "transformType: multiple values"; + properties.transformType = 1; + { + var error = $root.google.datastore.v1.Value.verify(message.minimum); + if (error) + return "minimum." + error; + } + } + if (message.appendMissingElements != null && message.hasOwnProperty("appendMissingElements")) { + if (properties.transformType === 1) + return "transformType: multiple values"; + properties.transformType = 1; + { + var error = $root.google.datastore.v1.ArrayValue.verify(message.appendMissingElements); + if (error) + return "appendMissingElements." + error; + } + } + if (message.removeAllFromArray != null && message.hasOwnProperty("removeAllFromArray")) { + if (properties.transformType === 1) + return "transformType: multiple values"; + properties.transformType = 1; + { + var error = $root.google.datastore.v1.ArrayValue.verify(message.removeAllFromArray); + if (error) + return "removeAllFromArray." + error; + } + } + return null; + }; + + /** + * Creates a PropertyTransform message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.PropertyTransform} PropertyTransform + */ + PropertyTransform.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.PropertyTransform) + return object; + var message = new $root.google.datastore.v1.PropertyTransform(); + if (object.property != null) + message.property = String(object.property); + switch (object.setToServerValue) { + default: + if (typeof object.setToServerValue === "number") { + message.setToServerValue = object.setToServerValue; + break; + } + break; + case "SERVER_VALUE_UNSPECIFIED": + case 0: + message.setToServerValue = 0; + break; + case "REQUEST_TIME": + case 1: + message.setToServerValue = 1; + break; + } + if (object.increment != null) { + if (typeof object.increment !== "object") + throw TypeError(".google.datastore.v1.PropertyTransform.increment: object expected"); + message.increment = $root.google.datastore.v1.Value.fromObject(object.increment); + } + if (object.maximum != null) { + if (typeof object.maximum !== "object") + throw TypeError(".google.datastore.v1.PropertyTransform.maximum: object expected"); + message.maximum = $root.google.datastore.v1.Value.fromObject(object.maximum); + } + if (object.minimum != null) { + if (typeof object.minimum !== "object") + throw TypeError(".google.datastore.v1.PropertyTransform.minimum: object expected"); + message.minimum = $root.google.datastore.v1.Value.fromObject(object.minimum); + } + if (object.appendMissingElements != null) { + if (typeof object.appendMissingElements !== "object") + throw TypeError(".google.datastore.v1.PropertyTransform.appendMissingElements: object expected"); + message.appendMissingElements = $root.google.datastore.v1.ArrayValue.fromObject(object.appendMissingElements); + } + if (object.removeAllFromArray != null) { + if (typeof object.removeAllFromArray !== "object") + throw TypeError(".google.datastore.v1.PropertyTransform.removeAllFromArray: object expected"); + message.removeAllFromArray = $root.google.datastore.v1.ArrayValue.fromObject(object.removeAllFromArray); + } + return message; + }; + + /** + * Creates a plain object from a PropertyTransform message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {google.datastore.v1.PropertyTransform} message PropertyTransform + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PropertyTransform.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.property = ""; + if (message.property != null && message.hasOwnProperty("property")) + object.property = message.property; + if (message.setToServerValue != null && message.hasOwnProperty("setToServerValue")) { + object.setToServerValue = options.enums === String ? $root.google.datastore.v1.PropertyTransform.ServerValue[message.setToServerValue] === undefined ? message.setToServerValue : $root.google.datastore.v1.PropertyTransform.ServerValue[message.setToServerValue] : message.setToServerValue; + if (options.oneofs) + object.transformType = "setToServerValue"; + } + if (message.increment != null && message.hasOwnProperty("increment")) { + object.increment = $root.google.datastore.v1.Value.toObject(message.increment, options); + if (options.oneofs) + object.transformType = "increment"; + } + if (message.maximum != null && message.hasOwnProperty("maximum")) { + object.maximum = $root.google.datastore.v1.Value.toObject(message.maximum, options); + if (options.oneofs) + object.transformType = "maximum"; + } + if (message.minimum != null && message.hasOwnProperty("minimum")) { + object.minimum = $root.google.datastore.v1.Value.toObject(message.minimum, options); + if (options.oneofs) + object.transformType = "minimum"; + } + if (message.appendMissingElements != null && message.hasOwnProperty("appendMissingElements")) { + object.appendMissingElements = $root.google.datastore.v1.ArrayValue.toObject(message.appendMissingElements, options); + if (options.oneofs) + object.transformType = "appendMissingElements"; + } + if (message.removeAllFromArray != null && message.hasOwnProperty("removeAllFromArray")) { + object.removeAllFromArray = $root.google.datastore.v1.ArrayValue.toObject(message.removeAllFromArray, options); + if (options.oneofs) + object.transformType = "removeAllFromArray"; + } + return object; + }; + + /** + * Converts this PropertyTransform to JSON. + * @function toJSON + * @memberof google.datastore.v1.PropertyTransform + * @instance + * @returns {Object.} JSON object + */ + PropertyTransform.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PropertyTransform + * @function getTypeUrl + * @memberof google.datastore.v1.PropertyTransform + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PropertyTransform.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.PropertyTransform"; + }; + + /** + * ServerValue enum. + * @name google.datastore.v1.PropertyTransform.ServerValue + * @enum {number} + * @property {number} SERVER_VALUE_UNSPECIFIED=0 SERVER_VALUE_UNSPECIFIED value + * @property {number} REQUEST_TIME=1 REQUEST_TIME value + */ + PropertyTransform.ServerValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "SERVER_VALUE_UNSPECIFIED"] = 0; + values[valuesById[1] = "REQUEST_TIME"] = 1; + return values; + })(); + + return PropertyTransform; + })(); + + v1.MutationResult = (function() { + + /** + * Properties of a MutationResult. + * @memberof google.datastore.v1 + * @interface IMutationResult + * @property {google.datastore.v1.IKey|null} [key] MutationResult key + * @property {number|Long|null} [version] MutationResult version + * @property {google.protobuf.ITimestamp|null} [createTime] MutationResult createTime + * @property {google.protobuf.ITimestamp|null} [updateTime] MutationResult updateTime + * @property {boolean|null} [conflictDetected] MutationResult conflictDetected + * @property {Array.|null} [transformResults] MutationResult transformResults + */ + + /** + * Constructs a new MutationResult. + * @memberof google.datastore.v1 + * @classdesc Represents a MutationResult. + * @implements IMutationResult + * @constructor + * @param {google.datastore.v1.IMutationResult=} [properties] Properties to set + */ + function MutationResult(properties) { + this.transformResults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MutationResult key. + * @member {google.datastore.v1.IKey|null|undefined} key + * @memberof google.datastore.v1.MutationResult + * @instance + */ + MutationResult.prototype.key = null; + + /** + * MutationResult version. + * @member {number|Long} version + * @memberof google.datastore.v1.MutationResult + * @instance + */ + MutationResult.prototype.version = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * MutationResult createTime. + * @member {google.protobuf.ITimestamp|null|undefined} createTime + * @memberof google.datastore.v1.MutationResult + * @instance + */ + MutationResult.prototype.createTime = null; + + /** + * MutationResult updateTime. + * @member {google.protobuf.ITimestamp|null|undefined} updateTime + * @memberof google.datastore.v1.MutationResult + * @instance + */ + MutationResult.prototype.updateTime = null; + + /** + * MutationResult conflictDetected. + * @member {boolean} conflictDetected + * @memberof google.datastore.v1.MutationResult + * @instance + */ + MutationResult.prototype.conflictDetected = false; + + /** + * MutationResult transformResults. + * @member {Array.} transformResults + * @memberof google.datastore.v1.MutationResult + * @instance + */ + MutationResult.prototype.transformResults = $util.emptyArray; + + /** + * Creates a new MutationResult instance using the specified properties. + * @function create + * @memberof google.datastore.v1.MutationResult + * @static + * @param {google.datastore.v1.IMutationResult=} [properties] Properties to set + * @returns {google.datastore.v1.MutationResult} MutationResult instance + */ + MutationResult.create = function create(properties) { + return new MutationResult(properties); + }; + + /** + * Encodes the specified MutationResult message. Does not implicitly {@link google.datastore.v1.MutationResult.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.MutationResult + * @static + * @param {google.datastore.v1.IMutationResult} message MutationResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MutationResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.key != null && Object.hasOwnProperty.call(message, "key")) + $root.google.datastore.v1.Key.encode(message.key, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.version); + if (message.conflictDetected != null && Object.hasOwnProperty.call(message, "conflictDetected")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.conflictDetected); + if (message.updateTime != null && Object.hasOwnProperty.call(message, "updateTime")) + $root.google.protobuf.Timestamp.encode(message.updateTime, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.createTime != null && Object.hasOwnProperty.call(message, "createTime")) + $root.google.protobuf.Timestamp.encode(message.createTime, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.transformResults != null && message.transformResults.length) + for (var i = 0; i < message.transformResults.length; ++i) + $root.google.datastore.v1.Value.encode(message.transformResults[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MutationResult message, length delimited. Does not implicitly {@link google.datastore.v1.MutationResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.MutationResult + * @static + * @param {google.datastore.v1.IMutationResult} message MutationResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MutationResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MutationResult message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.MutationResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.MutationResult} MutationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MutationResult.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.MutationResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.key = $root.google.datastore.v1.Key.decode(reader, reader.uint32()); + break; + } + case 4: { + message.version = reader.int64(); + break; + } + case 7: { + message.createTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 6: { + message.updateTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + case 5: { + message.conflictDetected = reader.bool(); + break; + } + case 8: { + if (!(message.transformResults && message.transformResults.length)) + message.transformResults = []; + message.transformResults.push($root.google.datastore.v1.Value.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MutationResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.MutationResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.MutationResult} MutationResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MutationResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MutationResult message. + * @function verify + * @memberof google.datastore.v1.MutationResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MutationResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.key != null && message.hasOwnProperty("key")) { + var error = $root.google.datastore.v1.Key.verify(message.key); + if (error) + return "key." + error; + } + if (message.version != null && message.hasOwnProperty("version")) + if (!$util.isInteger(message.version) && !(message.version && $util.isInteger(message.version.low) && $util.isInteger(message.version.high))) + return "version: integer|Long expected"; + if (message.createTime != null && message.hasOwnProperty("createTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.createTime); + if (error) + return "createTime." + error; + } + if (message.updateTime != null && message.hasOwnProperty("updateTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.updateTime); + if (error) + return "updateTime." + error; + } + if (message.conflictDetected != null && message.hasOwnProperty("conflictDetected")) + if (typeof message.conflictDetected !== "boolean") + return "conflictDetected: boolean expected"; + if (message.transformResults != null && message.hasOwnProperty("transformResults")) { + if (!Array.isArray(message.transformResults)) + return "transformResults: array expected"; + for (var i = 0; i < message.transformResults.length; ++i) { + var error = $root.google.datastore.v1.Value.verify(message.transformResults[i]); + if (error) + return "transformResults." + error; + } + } + return null; + }; + + /** + * Creates a MutationResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.MutationResult + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.MutationResult} MutationResult + */ + MutationResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.MutationResult) + return object; + var message = new $root.google.datastore.v1.MutationResult(); + if (object.key != null) { + if (typeof object.key !== "object") + throw TypeError(".google.datastore.v1.MutationResult.key: object expected"); + message.key = $root.google.datastore.v1.Key.fromObject(object.key); + } + if (object.version != null) + if ($util.Long) + (message.version = $util.Long.fromValue(object.version)).unsigned = false; + else if (typeof object.version === "string") + message.version = parseInt(object.version, 10); + else if (typeof object.version === "number") + message.version = object.version; + else if (typeof object.version === "object") + message.version = new $util.LongBits(object.version.low >>> 0, object.version.high >>> 0).toNumber(); + if (object.createTime != null) { + if (typeof object.createTime !== "object") + throw TypeError(".google.datastore.v1.MutationResult.createTime: object expected"); + message.createTime = $root.google.protobuf.Timestamp.fromObject(object.createTime); + } + if (object.updateTime != null) { + if (typeof object.updateTime !== "object") + throw TypeError(".google.datastore.v1.MutationResult.updateTime: object expected"); + message.updateTime = $root.google.protobuf.Timestamp.fromObject(object.updateTime); + } + if (object.conflictDetected != null) + message.conflictDetected = Boolean(object.conflictDetected); + if (object.transformResults) { + if (!Array.isArray(object.transformResults)) + throw TypeError(".google.datastore.v1.MutationResult.transformResults: array expected"); + message.transformResults = []; + for (var i = 0; i < object.transformResults.length; ++i) { + if (typeof object.transformResults[i] !== "object") + throw TypeError(".google.datastore.v1.MutationResult.transformResults: object expected"); + message.transformResults[i] = $root.google.datastore.v1.Value.fromObject(object.transformResults[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a MutationResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.MutationResult + * @static + * @param {google.datastore.v1.MutationResult} message MutationResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MutationResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.transformResults = []; + if (options.defaults) { + object.key = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.version = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.version = options.longs === String ? "0" : 0; + object.conflictDetected = false; + object.updateTime = null; + object.createTime = null; + } + if (message.key != null && message.hasOwnProperty("key")) + object.key = $root.google.datastore.v1.Key.toObject(message.key, options); + if (message.version != null && message.hasOwnProperty("version")) + if (typeof message.version === "number") + object.version = options.longs === String ? String(message.version) : message.version; + else + object.version = options.longs === String ? $util.Long.prototype.toString.call(message.version) : options.longs === Number ? new $util.LongBits(message.version.low >>> 0, message.version.high >>> 0).toNumber() : message.version; + if (message.conflictDetected != null && message.hasOwnProperty("conflictDetected")) + object.conflictDetected = message.conflictDetected; + if (message.updateTime != null && message.hasOwnProperty("updateTime")) + object.updateTime = $root.google.protobuf.Timestamp.toObject(message.updateTime, options); + if (message.createTime != null && message.hasOwnProperty("createTime")) + object.createTime = $root.google.protobuf.Timestamp.toObject(message.createTime, options); + if (message.transformResults && message.transformResults.length) { + object.transformResults = []; + for (var j = 0; j < message.transformResults.length; ++j) + object.transformResults[j] = $root.google.datastore.v1.Value.toObject(message.transformResults[j], options); + } + return object; + }; + + /** + * Converts this MutationResult to JSON. + * @function toJSON + * @memberof google.datastore.v1.MutationResult + * @instance + * @returns {Object.} JSON object + */ + MutationResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MutationResult + * @function getTypeUrl + * @memberof google.datastore.v1.MutationResult + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MutationResult.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.MutationResult"; + }; + + return MutationResult; + })(); + + v1.PropertyMask = (function() { + + /** + * Properties of a PropertyMask. + * @memberof google.datastore.v1 + * @interface IPropertyMask + * @property {Array.|null} [paths] PropertyMask paths + */ + + /** + * Constructs a new PropertyMask. + * @memberof google.datastore.v1 + * @classdesc Represents a PropertyMask. + * @implements IPropertyMask + * @constructor + * @param {google.datastore.v1.IPropertyMask=} [properties] Properties to set + */ + function PropertyMask(properties) { + this.paths = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PropertyMask paths. + * @member {Array.} paths + * @memberof google.datastore.v1.PropertyMask + * @instance + */ + PropertyMask.prototype.paths = $util.emptyArray; + + /** + * Creates a new PropertyMask instance using the specified properties. + * @function create + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {google.datastore.v1.IPropertyMask=} [properties] Properties to set + * @returns {google.datastore.v1.PropertyMask} PropertyMask instance + */ + PropertyMask.create = function create(properties) { + return new PropertyMask(properties); + }; + + /** + * Encodes the specified PropertyMask message. Does not implicitly {@link google.datastore.v1.PropertyMask.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {google.datastore.v1.IPropertyMask} message PropertyMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyMask.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.paths != null && message.paths.length) + for (var i = 0; i < message.paths.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.paths[i]); + return writer; + }; + + /** + * Encodes the specified PropertyMask message, length delimited. Does not implicitly {@link google.datastore.v1.PropertyMask.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {google.datastore.v1.IPropertyMask} message PropertyMask message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PropertyMask.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PropertyMask message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.PropertyMask} PropertyMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyMask.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.PropertyMask(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.paths && message.paths.length)) + message.paths = []; + message.paths.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PropertyMask message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.PropertyMask} PropertyMask + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PropertyMask.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PropertyMask message. + * @function verify + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PropertyMask.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.paths != null && message.hasOwnProperty("paths")) { + if (!Array.isArray(message.paths)) + return "paths: array expected"; + for (var i = 0; i < message.paths.length; ++i) + if (!$util.isString(message.paths[i])) + return "paths: string[] expected"; + } + return null; + }; + + /** + * Creates a PropertyMask message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.PropertyMask} PropertyMask + */ + PropertyMask.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.PropertyMask) + return object; + var message = new $root.google.datastore.v1.PropertyMask(); + if (object.paths) { + if (!Array.isArray(object.paths)) + throw TypeError(".google.datastore.v1.PropertyMask.paths: array expected"); + message.paths = []; + for (var i = 0; i < object.paths.length; ++i) + message.paths[i] = String(object.paths[i]); + } + return message; + }; + + /** + * Creates a plain object from a PropertyMask message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {google.datastore.v1.PropertyMask} message PropertyMask + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PropertyMask.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.paths = []; + if (message.paths && message.paths.length) { + object.paths = []; + for (var j = 0; j < message.paths.length; ++j) + object.paths[j] = message.paths[j]; + } + return object; + }; + + /** + * Converts this PropertyMask to JSON. + * @function toJSON + * @memberof google.datastore.v1.PropertyMask + * @instance + * @returns {Object.} JSON object + */ + PropertyMask.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PropertyMask + * @function getTypeUrl + * @memberof google.datastore.v1.PropertyMask + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PropertyMask.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.PropertyMask"; + }; + + return PropertyMask; + })(); + + v1.ReadOptions = (function() { + + /** + * Properties of a ReadOptions. + * @memberof google.datastore.v1 + * @interface IReadOptions + * @property {google.datastore.v1.ReadOptions.ReadConsistency|null} [readConsistency] ReadOptions readConsistency + * @property {Uint8Array|null} [transaction] ReadOptions transaction + * @property {google.datastore.v1.ITransactionOptions|null} [newTransaction] ReadOptions newTransaction + * @property {google.protobuf.ITimestamp|null} [readTime] ReadOptions readTime + */ + + /** + * Constructs a new ReadOptions. + * @memberof google.datastore.v1 + * @classdesc Represents a ReadOptions. + * @implements IReadOptions + * @constructor + * @param {google.datastore.v1.IReadOptions=} [properties] Properties to set + */ + function ReadOptions(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadOptions readConsistency. + * @member {google.datastore.v1.ReadOptions.ReadConsistency|null|undefined} readConsistency + * @memberof google.datastore.v1.ReadOptions + * @instance + */ + ReadOptions.prototype.readConsistency = null; + + /** + * ReadOptions transaction. + * @member {Uint8Array|null|undefined} transaction + * @memberof google.datastore.v1.ReadOptions + * @instance + */ + ReadOptions.prototype.transaction = null; + + /** + * ReadOptions newTransaction. + * @member {google.datastore.v1.ITransactionOptions|null|undefined} newTransaction + * @memberof google.datastore.v1.ReadOptions + * @instance + */ + ReadOptions.prototype.newTransaction = null; + + /** + * ReadOptions readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.datastore.v1.ReadOptions + * @instance + */ + ReadOptions.prototype.readTime = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * ReadOptions consistencyType. + * @member {"readConsistency"|"transaction"|"newTransaction"|"readTime"|undefined} consistencyType + * @memberof google.datastore.v1.ReadOptions + * @instance + */ + Object.defineProperty(ReadOptions.prototype, "consistencyType", { + get: $util.oneOfGetter($oneOfFields = ["readConsistency", "transaction", "newTransaction", "readTime"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new ReadOptions instance using the specified properties. + * @function create + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {google.datastore.v1.IReadOptions=} [properties] Properties to set + * @returns {google.datastore.v1.ReadOptions} ReadOptions instance + */ + ReadOptions.create = function create(properties) { + return new ReadOptions(properties); + }; + + /** + * Encodes the specified ReadOptions message. Does not implicitly {@link google.datastore.v1.ReadOptions.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {google.datastore.v1.IReadOptions} message ReadOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readConsistency != null && Object.hasOwnProperty.call(message, "readConsistency")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.readConsistency); + if (message.transaction != null && Object.hasOwnProperty.call(message, "transaction")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.transaction); + if (message.newTransaction != null && Object.hasOwnProperty.call(message, "newTransaction")) + $root.google.datastore.v1.TransactionOptions.encode(message.newTransaction, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.readTime != null && Object.hasOwnProperty.call(message, "readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ReadOptions message, length delimited. Does not implicitly {@link google.datastore.v1.ReadOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {google.datastore.v1.IReadOptions} message ReadOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReadOptions message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.ReadOptions} ReadOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.ReadOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.readConsistency = reader.int32(); + break; + } + case 2: { + message.transaction = reader.bytes(); + break; + } + case 3: { + message.newTransaction = $root.google.datastore.v1.TransactionOptions.decode(reader, reader.uint32()); + break; + } + case 4: { + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReadOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.ReadOptions} ReadOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReadOptions message. + * @function verify + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReadOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.readConsistency != null && message.hasOwnProperty("readConsistency")) { + properties.consistencyType = 1; + switch (message.readConsistency) { + default: + return "readConsistency: enum value expected"; + case 0: + case 1: + case 2: + break; + } + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + if (properties.consistencyType === 1) + return "consistencyType: multiple values"; + properties.consistencyType = 1; + if (!(message.transaction && typeof message.transaction.length === "number" || $util.isString(message.transaction))) + return "transaction: buffer expected"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + if (properties.consistencyType === 1) + return "consistencyType: multiple values"; + properties.consistencyType = 1; + { + var error = $root.google.datastore.v1.TransactionOptions.verify(message.newTransaction); + if (error) + return "newTransaction." + error; + } + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + if (properties.consistencyType === 1) + return "consistencyType: multiple values"; + properties.consistencyType = 1; + { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + } + return null; + }; + + /** + * Creates a ReadOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.ReadOptions} ReadOptions + */ + ReadOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.ReadOptions) + return object; + var message = new $root.google.datastore.v1.ReadOptions(); + switch (object.readConsistency) { + default: + if (typeof object.readConsistency === "number") { + message.readConsistency = object.readConsistency; + break; + } + break; + case "READ_CONSISTENCY_UNSPECIFIED": + case 0: + message.readConsistency = 0; + break; + case "STRONG": + case 1: + message.readConsistency = 1; + break; + case "EVENTUAL": + case 2: + message.readConsistency = 2; + break; + } + if (object.transaction != null) + if (typeof object.transaction === "string") + $util.base64.decode(object.transaction, message.transaction = $util.newBuffer($util.base64.length(object.transaction)), 0); + else if (object.transaction.length >= 0) + message.transaction = object.transaction; + if (object.newTransaction != null) { + if (typeof object.newTransaction !== "object") + throw TypeError(".google.datastore.v1.ReadOptions.newTransaction: object expected"); + message.newTransaction = $root.google.datastore.v1.TransactionOptions.fromObject(object.newTransaction); + } + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.datastore.v1.ReadOptions.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a ReadOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {google.datastore.v1.ReadOptions} message ReadOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReadOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.readConsistency != null && message.hasOwnProperty("readConsistency")) { + object.readConsistency = options.enums === String ? $root.google.datastore.v1.ReadOptions.ReadConsistency[message.readConsistency] === undefined ? message.readConsistency : $root.google.datastore.v1.ReadOptions.ReadConsistency[message.readConsistency] : message.readConsistency; + if (options.oneofs) + object.consistencyType = "readConsistency"; + } + if (message.transaction != null && message.hasOwnProperty("transaction")) { + object.transaction = options.bytes === String ? $util.base64.encode(message.transaction, 0, message.transaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.transaction) : message.transaction; + if (options.oneofs) + object.consistencyType = "transaction"; + } + if (message.newTransaction != null && message.hasOwnProperty("newTransaction")) { + object.newTransaction = $root.google.datastore.v1.TransactionOptions.toObject(message.newTransaction, options); + if (options.oneofs) + object.consistencyType = "newTransaction"; + } + if (message.readTime != null && message.hasOwnProperty("readTime")) { + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + if (options.oneofs) + object.consistencyType = "readTime"; + } + return object; + }; + + /** + * Converts this ReadOptions to JSON. + * @function toJSON + * @memberof google.datastore.v1.ReadOptions + * @instance + * @returns {Object.} JSON object + */ + ReadOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReadOptions + * @function getTypeUrl + * @memberof google.datastore.v1.ReadOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReadOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.ReadOptions"; + }; + + /** + * ReadConsistency enum. + * @name google.datastore.v1.ReadOptions.ReadConsistency + * @enum {number} + * @property {number} READ_CONSISTENCY_UNSPECIFIED=0 READ_CONSISTENCY_UNSPECIFIED value + * @property {number} STRONG=1 STRONG value + * @property {number} EVENTUAL=2 EVENTUAL value + */ + ReadOptions.ReadConsistency = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "READ_CONSISTENCY_UNSPECIFIED"] = 0; + values[valuesById[1] = "STRONG"] = 1; + values[valuesById[2] = "EVENTUAL"] = 2; + return values; + })(); + + return ReadOptions; + })(); + + v1.TransactionOptions = (function() { + + /** + * Properties of a TransactionOptions. + * @memberof google.datastore.v1 + * @interface ITransactionOptions + * @property {google.datastore.v1.TransactionOptions.IReadWrite|null} [readWrite] TransactionOptions readWrite + * @property {google.datastore.v1.TransactionOptions.IReadOnly|null} [readOnly] TransactionOptions readOnly + */ + + /** + * Constructs a new TransactionOptions. + * @memberof google.datastore.v1 + * @classdesc Represents a TransactionOptions. + * @implements ITransactionOptions + * @constructor + * @param {google.datastore.v1.ITransactionOptions=} [properties] Properties to set + */ + function TransactionOptions(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * TransactionOptions readWrite. + * @member {google.datastore.v1.TransactionOptions.IReadWrite|null|undefined} readWrite + * @memberof google.datastore.v1.TransactionOptions + * @instance + */ + TransactionOptions.prototype.readWrite = null; + + /** + * TransactionOptions readOnly. + * @member {google.datastore.v1.TransactionOptions.IReadOnly|null|undefined} readOnly + * @memberof google.datastore.v1.TransactionOptions + * @instance + */ + TransactionOptions.prototype.readOnly = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * TransactionOptions mode. + * @member {"readWrite"|"readOnly"|undefined} mode + * @memberof google.datastore.v1.TransactionOptions + * @instance + */ + Object.defineProperty(TransactionOptions.prototype, "mode", { + get: $util.oneOfGetter($oneOfFields = ["readWrite", "readOnly"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new TransactionOptions instance using the specified properties. + * @function create + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {google.datastore.v1.ITransactionOptions=} [properties] Properties to set + * @returns {google.datastore.v1.TransactionOptions} TransactionOptions instance + */ + TransactionOptions.create = function create(properties) { + return new TransactionOptions(properties); + }; + + /** + * Encodes the specified TransactionOptions message. Does not implicitly {@link google.datastore.v1.TransactionOptions.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {google.datastore.v1.ITransactionOptions} message TransactionOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TransactionOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readWrite != null && Object.hasOwnProperty.call(message, "readWrite")) + $root.google.datastore.v1.TransactionOptions.ReadWrite.encode(message.readWrite, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.readOnly != null && Object.hasOwnProperty.call(message, "readOnly")) + $root.google.datastore.v1.TransactionOptions.ReadOnly.encode(message.readOnly, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified TransactionOptions message, length delimited. Does not implicitly {@link google.datastore.v1.TransactionOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {google.datastore.v1.ITransactionOptions} message TransactionOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + TransactionOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.TransactionOptions} TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TransactionOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.TransactionOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.readWrite = $root.google.datastore.v1.TransactionOptions.ReadWrite.decode(reader, reader.uint32()); + break; + } + case 2: { + message.readOnly = $root.google.datastore.v1.TransactionOptions.ReadOnly.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a TransactionOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.TransactionOptions} TransactionOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + TransactionOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a TransactionOptions message. + * @function verify + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + TransactionOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.readWrite != null && message.hasOwnProperty("readWrite")) { + properties.mode = 1; + { + var error = $root.google.datastore.v1.TransactionOptions.ReadWrite.verify(message.readWrite); + if (error) + return "readWrite." + error; + } + } + if (message.readOnly != null && message.hasOwnProperty("readOnly")) { + if (properties.mode === 1) + return "mode: multiple values"; + properties.mode = 1; + { + var error = $root.google.datastore.v1.TransactionOptions.ReadOnly.verify(message.readOnly); + if (error) + return "readOnly." + error; + } + } + return null; + }; + + /** + * Creates a TransactionOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.TransactionOptions} TransactionOptions + */ + TransactionOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.TransactionOptions) + return object; + var message = new $root.google.datastore.v1.TransactionOptions(); + if (object.readWrite != null) { + if (typeof object.readWrite !== "object") + throw TypeError(".google.datastore.v1.TransactionOptions.readWrite: object expected"); + message.readWrite = $root.google.datastore.v1.TransactionOptions.ReadWrite.fromObject(object.readWrite); + } + if (object.readOnly != null) { + if (typeof object.readOnly !== "object") + throw TypeError(".google.datastore.v1.TransactionOptions.readOnly: object expected"); + message.readOnly = $root.google.datastore.v1.TransactionOptions.ReadOnly.fromObject(object.readOnly); + } + return message; + }; + + /** + * Creates a plain object from a TransactionOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {google.datastore.v1.TransactionOptions} message TransactionOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + TransactionOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.readWrite != null && message.hasOwnProperty("readWrite")) { + object.readWrite = $root.google.datastore.v1.TransactionOptions.ReadWrite.toObject(message.readWrite, options); + if (options.oneofs) + object.mode = "readWrite"; + } + if (message.readOnly != null && message.hasOwnProperty("readOnly")) { + object.readOnly = $root.google.datastore.v1.TransactionOptions.ReadOnly.toObject(message.readOnly, options); + if (options.oneofs) + object.mode = "readOnly"; + } + return object; + }; + + /** + * Converts this TransactionOptions to JSON. + * @function toJSON + * @memberof google.datastore.v1.TransactionOptions + * @instance + * @returns {Object.} JSON object + */ + TransactionOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for TransactionOptions + * @function getTypeUrl + * @memberof google.datastore.v1.TransactionOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + TransactionOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.TransactionOptions"; + }; + + TransactionOptions.ReadWrite = (function() { + + /** + * Properties of a ReadWrite. + * @memberof google.datastore.v1.TransactionOptions + * @interface IReadWrite + * @property {Uint8Array|null} [previousTransaction] ReadWrite previousTransaction + */ + + /** + * Constructs a new ReadWrite. + * @memberof google.datastore.v1.TransactionOptions + * @classdesc Represents a ReadWrite. + * @implements IReadWrite + * @constructor + * @param {google.datastore.v1.TransactionOptions.IReadWrite=} [properties] Properties to set + */ + function ReadWrite(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadWrite previousTransaction. + * @member {Uint8Array} previousTransaction + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @instance + */ + ReadWrite.prototype.previousTransaction = $util.newBuffer([]); + + /** + * Creates a new ReadWrite instance using the specified properties. + * @function create + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {google.datastore.v1.TransactionOptions.IReadWrite=} [properties] Properties to set + * @returns {google.datastore.v1.TransactionOptions.ReadWrite} ReadWrite instance + */ + ReadWrite.create = function create(properties) { + return new ReadWrite(properties); + }; + + /** + * Encodes the specified ReadWrite message. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadWrite.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {google.datastore.v1.TransactionOptions.IReadWrite} message ReadWrite message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadWrite.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.previousTransaction != null && Object.hasOwnProperty.call(message, "previousTransaction")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.previousTransaction); + return writer; + }; + + /** + * Encodes the specified ReadWrite message, length delimited. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadWrite.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {google.datastore.v1.TransactionOptions.IReadWrite} message ReadWrite message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadWrite.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReadWrite message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.TransactionOptions.ReadWrite} ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadWrite.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.TransactionOptions.ReadWrite(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.previousTransaction = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReadWrite message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.TransactionOptions.ReadWrite} ReadWrite + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadWrite.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReadWrite message. + * @function verify + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReadWrite.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.previousTransaction != null && message.hasOwnProperty("previousTransaction")) + if (!(message.previousTransaction && typeof message.previousTransaction.length === "number" || $util.isString(message.previousTransaction))) + return "previousTransaction: buffer expected"; + return null; + }; + + /** + * Creates a ReadWrite message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.TransactionOptions.ReadWrite} ReadWrite + */ + ReadWrite.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.TransactionOptions.ReadWrite) + return object; + var message = new $root.google.datastore.v1.TransactionOptions.ReadWrite(); + if (object.previousTransaction != null) + if (typeof object.previousTransaction === "string") + $util.base64.decode(object.previousTransaction, message.previousTransaction = $util.newBuffer($util.base64.length(object.previousTransaction)), 0); + else if (object.previousTransaction.length >= 0) + message.previousTransaction = object.previousTransaction; + return message; + }; + + /** + * Creates a plain object from a ReadWrite message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {google.datastore.v1.TransactionOptions.ReadWrite} message ReadWrite + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReadWrite.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.previousTransaction = ""; + else { + object.previousTransaction = []; + if (options.bytes !== Array) + object.previousTransaction = $util.newBuffer(object.previousTransaction); + } + if (message.previousTransaction != null && message.hasOwnProperty("previousTransaction")) + object.previousTransaction = options.bytes === String ? $util.base64.encode(message.previousTransaction, 0, message.previousTransaction.length) : options.bytes === Array ? Array.prototype.slice.call(message.previousTransaction) : message.previousTransaction; + return object; + }; + + /** + * Converts this ReadWrite to JSON. + * @function toJSON + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @instance + * @returns {Object.} JSON object + */ + ReadWrite.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReadWrite + * @function getTypeUrl + * @memberof google.datastore.v1.TransactionOptions.ReadWrite + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReadWrite.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.TransactionOptions.ReadWrite"; + }; + + return ReadWrite; + })(); + + TransactionOptions.ReadOnly = (function() { + + /** + * Properties of a ReadOnly. + * @memberof google.datastore.v1.TransactionOptions + * @interface IReadOnly + * @property {google.protobuf.ITimestamp|null} [readTime] ReadOnly readTime + */ + + /** + * Constructs a new ReadOnly. + * @memberof google.datastore.v1.TransactionOptions + * @classdesc Represents a ReadOnly. + * @implements IReadOnly + * @constructor + * @param {google.datastore.v1.TransactionOptions.IReadOnly=} [properties] Properties to set + */ + function ReadOnly(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReadOnly readTime. + * @member {google.protobuf.ITimestamp|null|undefined} readTime + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @instance + */ + ReadOnly.prototype.readTime = null; + + /** + * Creates a new ReadOnly instance using the specified properties. + * @function create + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {google.datastore.v1.TransactionOptions.IReadOnly=} [properties] Properties to set + * @returns {google.datastore.v1.TransactionOptions.ReadOnly} ReadOnly instance + */ + ReadOnly.create = function create(properties) { + return new ReadOnly(properties); + }; + + /** + * Encodes the specified ReadOnly message. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadOnly.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {google.datastore.v1.TransactionOptions.IReadOnly} message ReadOnly message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadOnly.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.readTime != null && Object.hasOwnProperty.call(message, "readTime")) + $root.google.protobuf.Timestamp.encode(message.readTime, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ReadOnly message, length delimited. Does not implicitly {@link google.datastore.v1.TransactionOptions.ReadOnly.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {google.datastore.v1.TransactionOptions.IReadOnly} message ReadOnly message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReadOnly.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReadOnly message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.TransactionOptions.ReadOnly} ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadOnly.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.TransactionOptions.ReadOnly(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.readTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReadOnly message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.TransactionOptions.ReadOnly} ReadOnly + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReadOnly.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReadOnly message. + * @function verify + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReadOnly.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.readTime != null && message.hasOwnProperty("readTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.readTime); + if (error) + return "readTime." + error; + } + return null; + }; + + /** + * Creates a ReadOnly message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.TransactionOptions.ReadOnly} ReadOnly + */ + ReadOnly.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.TransactionOptions.ReadOnly) + return object; + var message = new $root.google.datastore.v1.TransactionOptions.ReadOnly(); + if (object.readTime != null) { + if (typeof object.readTime !== "object") + throw TypeError(".google.datastore.v1.TransactionOptions.ReadOnly.readTime: object expected"); + message.readTime = $root.google.protobuf.Timestamp.fromObject(object.readTime); + } + return message; + }; + + /** + * Creates a plain object from a ReadOnly message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {google.datastore.v1.TransactionOptions.ReadOnly} message ReadOnly + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReadOnly.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.readTime = null; + if (message.readTime != null && message.hasOwnProperty("readTime")) + object.readTime = $root.google.protobuf.Timestamp.toObject(message.readTime, options); + return object; + }; + + /** + * Converts this ReadOnly to JSON. + * @function toJSON + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @instance + * @returns {Object.} JSON object + */ + ReadOnly.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReadOnly + * @function getTypeUrl + * @memberof google.datastore.v1.TransactionOptions.ReadOnly + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReadOnly.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.TransactionOptions.ReadOnly"; + }; + + return ReadOnly; + })(); + + return TransactionOptions; + })(); + + v1.ExplainOptions = (function() { + + /** + * Properties of an ExplainOptions. + * @memberof google.datastore.v1 + * @interface IExplainOptions + * @property {boolean|null} [analyze] ExplainOptions analyze + */ + + /** + * Constructs a new ExplainOptions. + * @memberof google.datastore.v1 + * @classdesc Represents an ExplainOptions. + * @implements IExplainOptions + * @constructor + * @param {google.datastore.v1.IExplainOptions=} [properties] Properties to set + */ + function ExplainOptions(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExplainOptions analyze. + * @member {boolean} analyze + * @memberof google.datastore.v1.ExplainOptions + * @instance + */ + ExplainOptions.prototype.analyze = false; + + /** + * Creates a new ExplainOptions instance using the specified properties. + * @function create + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {google.datastore.v1.IExplainOptions=} [properties] Properties to set + * @returns {google.datastore.v1.ExplainOptions} ExplainOptions instance + */ + ExplainOptions.create = function create(properties) { + return new ExplainOptions(properties); + }; + + /** + * Encodes the specified ExplainOptions message. Does not implicitly {@link google.datastore.v1.ExplainOptions.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {google.datastore.v1.IExplainOptions} message ExplainOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExplainOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.analyze != null && Object.hasOwnProperty.call(message, "analyze")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.analyze); + return writer; + }; + + /** + * Encodes the specified ExplainOptions message, length delimited. Does not implicitly {@link google.datastore.v1.ExplainOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {google.datastore.v1.IExplainOptions} message ExplainOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExplainOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExplainOptions message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.ExplainOptions} ExplainOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExplainOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.ExplainOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.analyze = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExplainOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.ExplainOptions} ExplainOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExplainOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExplainOptions message. + * @function verify + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExplainOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.analyze != null && message.hasOwnProperty("analyze")) + if (typeof message.analyze !== "boolean") + return "analyze: boolean expected"; + return null; + }; + + /** + * Creates an ExplainOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.ExplainOptions} ExplainOptions + */ + ExplainOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.ExplainOptions) + return object; + var message = new $root.google.datastore.v1.ExplainOptions(); + if (object.analyze != null) + message.analyze = Boolean(object.analyze); + return message; + }; + + /** + * Creates a plain object from an ExplainOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {google.datastore.v1.ExplainOptions} message ExplainOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExplainOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.analyze = false; + if (message.analyze != null && message.hasOwnProperty("analyze")) + object.analyze = message.analyze; + return object; + }; + + /** + * Converts this ExplainOptions to JSON. + * @function toJSON + * @memberof google.datastore.v1.ExplainOptions + * @instance + * @returns {Object.} JSON object + */ + ExplainOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExplainOptions + * @function getTypeUrl + * @memberof google.datastore.v1.ExplainOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExplainOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.ExplainOptions"; + }; + + return ExplainOptions; + })(); + + v1.ExplainMetrics = (function() { + + /** + * Properties of an ExplainMetrics. + * @memberof google.datastore.v1 + * @interface IExplainMetrics + * @property {google.datastore.v1.IPlanSummary|null} [planSummary] ExplainMetrics planSummary + * @property {google.datastore.v1.IExecutionStats|null} [executionStats] ExplainMetrics executionStats + */ + + /** + * Constructs a new ExplainMetrics. + * @memberof google.datastore.v1 + * @classdesc Represents an ExplainMetrics. + * @implements IExplainMetrics + * @constructor + * @param {google.datastore.v1.IExplainMetrics=} [properties] Properties to set + */ + function ExplainMetrics(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExplainMetrics planSummary. + * @member {google.datastore.v1.IPlanSummary|null|undefined} planSummary + * @memberof google.datastore.v1.ExplainMetrics + * @instance + */ + ExplainMetrics.prototype.planSummary = null; + + /** + * ExplainMetrics executionStats. + * @member {google.datastore.v1.IExecutionStats|null|undefined} executionStats + * @memberof google.datastore.v1.ExplainMetrics + * @instance + */ + ExplainMetrics.prototype.executionStats = null; + + /** + * Creates a new ExplainMetrics instance using the specified properties. + * @function create + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {google.datastore.v1.IExplainMetrics=} [properties] Properties to set + * @returns {google.datastore.v1.ExplainMetrics} ExplainMetrics instance + */ + ExplainMetrics.create = function create(properties) { + return new ExplainMetrics(properties); + }; + + /** + * Encodes the specified ExplainMetrics message. Does not implicitly {@link google.datastore.v1.ExplainMetrics.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {google.datastore.v1.IExplainMetrics} message ExplainMetrics message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExplainMetrics.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.planSummary != null && Object.hasOwnProperty.call(message, "planSummary")) + $root.google.datastore.v1.PlanSummary.encode(message.planSummary, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.executionStats != null && Object.hasOwnProperty.call(message, "executionStats")) + $root.google.datastore.v1.ExecutionStats.encode(message.executionStats, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExplainMetrics message, length delimited. Does not implicitly {@link google.datastore.v1.ExplainMetrics.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {google.datastore.v1.IExplainMetrics} message ExplainMetrics message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExplainMetrics.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExplainMetrics message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.ExplainMetrics} ExplainMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExplainMetrics.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.ExplainMetrics(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.planSummary = $root.google.datastore.v1.PlanSummary.decode(reader, reader.uint32()); + break; + } + case 2: { + message.executionStats = $root.google.datastore.v1.ExecutionStats.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExplainMetrics message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.ExplainMetrics} ExplainMetrics + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExplainMetrics.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExplainMetrics message. + * @function verify + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExplainMetrics.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.planSummary != null && message.hasOwnProperty("planSummary")) { + var error = $root.google.datastore.v1.PlanSummary.verify(message.planSummary); + if (error) + return "planSummary." + error; + } + if (message.executionStats != null && message.hasOwnProperty("executionStats")) { + var error = $root.google.datastore.v1.ExecutionStats.verify(message.executionStats); + if (error) + return "executionStats." + error; + } + return null; + }; + + /** + * Creates an ExplainMetrics message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.ExplainMetrics} ExplainMetrics + */ + ExplainMetrics.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.ExplainMetrics) + return object; + var message = new $root.google.datastore.v1.ExplainMetrics(); + if (object.planSummary != null) { + if (typeof object.planSummary !== "object") + throw TypeError(".google.datastore.v1.ExplainMetrics.planSummary: object expected"); + message.planSummary = $root.google.datastore.v1.PlanSummary.fromObject(object.planSummary); + } + if (object.executionStats != null) { + if (typeof object.executionStats !== "object") + throw TypeError(".google.datastore.v1.ExplainMetrics.executionStats: object expected"); + message.executionStats = $root.google.datastore.v1.ExecutionStats.fromObject(object.executionStats); + } + return message; + }; + + /** + * Creates a plain object from an ExplainMetrics message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {google.datastore.v1.ExplainMetrics} message ExplainMetrics + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExplainMetrics.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.planSummary = null; + object.executionStats = null; + } + if (message.planSummary != null && message.hasOwnProperty("planSummary")) + object.planSummary = $root.google.datastore.v1.PlanSummary.toObject(message.planSummary, options); + if (message.executionStats != null && message.hasOwnProperty("executionStats")) + object.executionStats = $root.google.datastore.v1.ExecutionStats.toObject(message.executionStats, options); + return object; + }; + + /** + * Converts this ExplainMetrics to JSON. + * @function toJSON + * @memberof google.datastore.v1.ExplainMetrics + * @instance + * @returns {Object.} JSON object + */ + ExplainMetrics.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExplainMetrics + * @function getTypeUrl + * @memberof google.datastore.v1.ExplainMetrics + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExplainMetrics.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.ExplainMetrics"; + }; + + return ExplainMetrics; + })(); + + v1.PlanSummary = (function() { + + /** + * Properties of a PlanSummary. + * @memberof google.datastore.v1 + * @interface IPlanSummary + * @property {Array.|null} [indexesUsed] PlanSummary indexesUsed + */ + + /** + * Constructs a new PlanSummary. + * @memberof google.datastore.v1 + * @classdesc Represents a PlanSummary. + * @implements IPlanSummary + * @constructor + * @param {google.datastore.v1.IPlanSummary=} [properties] Properties to set + */ + function PlanSummary(properties) { + this.indexesUsed = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PlanSummary indexesUsed. + * @member {Array.} indexesUsed + * @memberof google.datastore.v1.PlanSummary + * @instance + */ + PlanSummary.prototype.indexesUsed = $util.emptyArray; + + /** + * Creates a new PlanSummary instance using the specified properties. + * @function create + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {google.datastore.v1.IPlanSummary=} [properties] Properties to set + * @returns {google.datastore.v1.PlanSummary} PlanSummary instance + */ + PlanSummary.create = function create(properties) { + return new PlanSummary(properties); + }; + + /** + * Encodes the specified PlanSummary message. Does not implicitly {@link google.datastore.v1.PlanSummary.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {google.datastore.v1.IPlanSummary} message PlanSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlanSummary.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.indexesUsed != null && message.indexesUsed.length) + for (var i = 0; i < message.indexesUsed.length; ++i) + $root.google.protobuf.Struct.encode(message.indexesUsed[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PlanSummary message, length delimited. Does not implicitly {@link google.datastore.v1.PlanSummary.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {google.datastore.v1.IPlanSummary} message PlanSummary message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PlanSummary.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PlanSummary message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.PlanSummary} PlanSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlanSummary.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.PlanSummary(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.indexesUsed && message.indexesUsed.length)) + message.indexesUsed = []; + message.indexesUsed.push($root.google.protobuf.Struct.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PlanSummary message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.PlanSummary} PlanSummary + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PlanSummary.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PlanSummary message. + * @function verify + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PlanSummary.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.indexesUsed != null && message.hasOwnProperty("indexesUsed")) { + if (!Array.isArray(message.indexesUsed)) + return "indexesUsed: array expected"; + for (var i = 0; i < message.indexesUsed.length; ++i) { + var error = $root.google.protobuf.Struct.verify(message.indexesUsed[i]); + if (error) + return "indexesUsed." + error; + } + } + return null; + }; + + /** + * Creates a PlanSummary message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.PlanSummary} PlanSummary + */ + PlanSummary.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.PlanSummary) + return object; + var message = new $root.google.datastore.v1.PlanSummary(); + if (object.indexesUsed) { + if (!Array.isArray(object.indexesUsed)) + throw TypeError(".google.datastore.v1.PlanSummary.indexesUsed: array expected"); + message.indexesUsed = []; + for (var i = 0; i < object.indexesUsed.length; ++i) { + if (typeof object.indexesUsed[i] !== "object") + throw TypeError(".google.datastore.v1.PlanSummary.indexesUsed: object expected"); + message.indexesUsed[i] = $root.google.protobuf.Struct.fromObject(object.indexesUsed[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a PlanSummary message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {google.datastore.v1.PlanSummary} message PlanSummary + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PlanSummary.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.indexesUsed = []; + if (message.indexesUsed && message.indexesUsed.length) { + object.indexesUsed = []; + for (var j = 0; j < message.indexesUsed.length; ++j) + object.indexesUsed[j] = $root.google.protobuf.Struct.toObject(message.indexesUsed[j], options); + } + return object; + }; + + /** + * Converts this PlanSummary to JSON. + * @function toJSON + * @memberof google.datastore.v1.PlanSummary + * @instance + * @returns {Object.} JSON object + */ + PlanSummary.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PlanSummary + * @function getTypeUrl + * @memberof google.datastore.v1.PlanSummary + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PlanSummary.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.PlanSummary"; + }; + + return PlanSummary; + })(); + + v1.ExecutionStats = (function() { + + /** + * Properties of an ExecutionStats. + * @memberof google.datastore.v1 + * @interface IExecutionStats + * @property {number|Long|null} [resultsReturned] ExecutionStats resultsReturned + * @property {google.protobuf.IDuration|null} [executionDuration] ExecutionStats executionDuration + * @property {number|Long|null} [readOperations] ExecutionStats readOperations + * @property {google.protobuf.IStruct|null} [debugStats] ExecutionStats debugStats + */ + + /** + * Constructs a new ExecutionStats. + * @memberof google.datastore.v1 + * @classdesc Represents an ExecutionStats. + * @implements IExecutionStats + * @constructor + * @param {google.datastore.v1.IExecutionStats=} [properties] Properties to set + */ + function ExecutionStats(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExecutionStats resultsReturned. + * @member {number|Long} resultsReturned + * @memberof google.datastore.v1.ExecutionStats + * @instance + */ + ExecutionStats.prototype.resultsReturned = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ExecutionStats executionDuration. + * @member {google.protobuf.IDuration|null|undefined} executionDuration + * @memberof google.datastore.v1.ExecutionStats + * @instance + */ + ExecutionStats.prototype.executionDuration = null; + + /** + * ExecutionStats readOperations. + * @member {number|Long} readOperations + * @memberof google.datastore.v1.ExecutionStats + * @instance + */ + ExecutionStats.prototype.readOperations = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * ExecutionStats debugStats. + * @member {google.protobuf.IStruct|null|undefined} debugStats + * @memberof google.datastore.v1.ExecutionStats + * @instance + */ + ExecutionStats.prototype.debugStats = null; + + /** + * Creates a new ExecutionStats instance using the specified properties. + * @function create + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {google.datastore.v1.IExecutionStats=} [properties] Properties to set + * @returns {google.datastore.v1.ExecutionStats} ExecutionStats instance + */ + ExecutionStats.create = function create(properties) { + return new ExecutionStats(properties); + }; + + /** + * Encodes the specified ExecutionStats message. Does not implicitly {@link google.datastore.v1.ExecutionStats.verify|verify} messages. + * @function encode + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {google.datastore.v1.IExecutionStats} message ExecutionStats message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExecutionStats.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.resultsReturned != null && Object.hasOwnProperty.call(message, "resultsReturned")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.resultsReturned); + if (message.executionDuration != null && Object.hasOwnProperty.call(message, "executionDuration")) + $root.google.protobuf.Duration.encode(message.executionDuration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.readOperations != null && Object.hasOwnProperty.call(message, "readOperations")) + writer.uint32(/* id 4, wireType 0 =*/32).int64(message.readOperations); + if (message.debugStats != null && Object.hasOwnProperty.call(message, "debugStats")) + $root.google.protobuf.Struct.encode(message.debugStats, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExecutionStats message, length delimited. Does not implicitly {@link google.datastore.v1.ExecutionStats.verify|verify} messages. + * @function encodeDelimited + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {google.datastore.v1.IExecutionStats} message ExecutionStats message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExecutionStats.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExecutionStats message from the specified reader or buffer. + * @function decode + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.datastore.v1.ExecutionStats} ExecutionStats + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExecutionStats.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.datastore.v1.ExecutionStats(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.resultsReturned = reader.int64(); + break; + } + case 3: { + message.executionDuration = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 4: { + message.readOperations = reader.int64(); + break; + } + case 5: { + message.debugStats = $root.google.protobuf.Struct.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExecutionStats message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.datastore.v1.ExecutionStats} ExecutionStats + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExecutionStats.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExecutionStats message. + * @function verify + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExecutionStats.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.resultsReturned != null && message.hasOwnProperty("resultsReturned")) + if (!$util.isInteger(message.resultsReturned) && !(message.resultsReturned && $util.isInteger(message.resultsReturned.low) && $util.isInteger(message.resultsReturned.high))) + return "resultsReturned: integer|Long expected"; + if (message.executionDuration != null && message.hasOwnProperty("executionDuration")) { + var error = $root.google.protobuf.Duration.verify(message.executionDuration); + if (error) + return "executionDuration." + error; + } + if (message.readOperations != null && message.hasOwnProperty("readOperations")) + if (!$util.isInteger(message.readOperations) && !(message.readOperations && $util.isInteger(message.readOperations.low) && $util.isInteger(message.readOperations.high))) + return "readOperations: integer|Long expected"; + if (message.debugStats != null && message.hasOwnProperty("debugStats")) { + var error = $root.google.protobuf.Struct.verify(message.debugStats); + if (error) + return "debugStats." + error; + } + return null; + }; + + /** + * Creates an ExecutionStats message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {Object.} object Plain object + * @returns {google.datastore.v1.ExecutionStats} ExecutionStats + */ + ExecutionStats.fromObject = function fromObject(object) { + if (object instanceof $root.google.datastore.v1.ExecutionStats) + return object; + var message = new $root.google.datastore.v1.ExecutionStats(); + if (object.resultsReturned != null) + if ($util.Long) + (message.resultsReturned = $util.Long.fromValue(object.resultsReturned)).unsigned = false; + else if (typeof object.resultsReturned === "string") + message.resultsReturned = parseInt(object.resultsReturned, 10); + else if (typeof object.resultsReturned === "number") + message.resultsReturned = object.resultsReturned; + else if (typeof object.resultsReturned === "object") + message.resultsReturned = new $util.LongBits(object.resultsReturned.low >>> 0, object.resultsReturned.high >>> 0).toNumber(); + if (object.executionDuration != null) { + if (typeof object.executionDuration !== "object") + throw TypeError(".google.datastore.v1.ExecutionStats.executionDuration: object expected"); + message.executionDuration = $root.google.protobuf.Duration.fromObject(object.executionDuration); + } + if (object.readOperations != null) + if ($util.Long) + (message.readOperations = $util.Long.fromValue(object.readOperations)).unsigned = false; + else if (typeof object.readOperations === "string") + message.readOperations = parseInt(object.readOperations, 10); + else if (typeof object.readOperations === "number") + message.readOperations = object.readOperations; + else if (typeof object.readOperations === "object") + message.readOperations = new $util.LongBits(object.readOperations.low >>> 0, object.readOperations.high >>> 0).toNumber(); + if (object.debugStats != null) { + if (typeof object.debugStats !== "object") + throw TypeError(".google.datastore.v1.ExecutionStats.debugStats: object expected"); + message.debugStats = $root.google.protobuf.Struct.fromObject(object.debugStats); + } + return message; + }; + + /** + * Creates a plain object from an ExecutionStats message. Also converts values to other types if specified. + * @function toObject + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {google.datastore.v1.ExecutionStats} message ExecutionStats + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExecutionStats.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.resultsReturned = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.resultsReturned = options.longs === String ? "0" : 0; + object.executionDuration = null; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.readOperations = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.readOperations = options.longs === String ? "0" : 0; + object.debugStats = null; + } + if (message.resultsReturned != null && message.hasOwnProperty("resultsReturned")) + if (typeof message.resultsReturned === "number") + object.resultsReturned = options.longs === String ? String(message.resultsReturned) : message.resultsReturned; + else + object.resultsReturned = options.longs === String ? $util.Long.prototype.toString.call(message.resultsReturned) : options.longs === Number ? new $util.LongBits(message.resultsReturned.low >>> 0, message.resultsReturned.high >>> 0).toNumber() : message.resultsReturned; + if (message.executionDuration != null && message.hasOwnProperty("executionDuration")) + object.executionDuration = $root.google.protobuf.Duration.toObject(message.executionDuration, options); + if (message.readOperations != null && message.hasOwnProperty("readOperations")) + if (typeof message.readOperations === "number") + object.readOperations = options.longs === String ? String(message.readOperations) : message.readOperations; + else + object.readOperations = options.longs === String ? $util.Long.prototype.toString.call(message.readOperations) : options.longs === Number ? new $util.LongBits(message.readOperations.low >>> 0, message.readOperations.high >>> 0).toNumber() : message.readOperations; + if (message.debugStats != null && message.hasOwnProperty("debugStats")) + object.debugStats = $root.google.protobuf.Struct.toObject(message.debugStats, options); + return object; + }; + + /** + * Converts this ExecutionStats to JSON. + * @function toJSON + * @memberof google.datastore.v1.ExecutionStats + * @instance + * @returns {Object.} JSON object + */ + ExecutionStats.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExecutionStats + * @function getTypeUrl + * @memberof google.datastore.v1.ExecutionStats + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExecutionStats.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.datastore.v1.ExecutionStats"; + }; + + return ExecutionStats; + })(); + + return v1; + })(); + + return datastore; + })(); + + google.api = (function() { + + /** + * Namespace api. + * @memberof google + * @namespace + */ + var api = {}; + + api.Http = (function() { + + /** + * Properties of a Http. + * @memberof google.api + * @interface IHttp + * @property {Array.|null} [rules] Http rules + * @property {boolean|null} [fullyDecodeReservedExpansion] Http fullyDecodeReservedExpansion + */ + + /** + * Constructs a new Http. + * @memberof google.api + * @classdesc Represents a Http. + * @implements IHttp + * @constructor + * @param {google.api.IHttp=} [properties] Properties to set + */ + function Http(properties) { + this.rules = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Http rules. + * @member {Array.} rules + * @memberof google.api.Http + * @instance + */ + Http.prototype.rules = $util.emptyArray; + + /** + * Http fullyDecodeReservedExpansion. + * @member {boolean} fullyDecodeReservedExpansion + * @memberof google.api.Http + * @instance + */ + Http.prototype.fullyDecodeReservedExpansion = false; + + /** + * Creates a new Http instance using the specified properties. + * @function create + * @memberof google.api.Http + * @static + * @param {google.api.IHttp=} [properties] Properties to set + * @returns {google.api.Http} Http instance + */ + Http.create = function create(properties) { + return new Http(properties); + }; + + /** + * Encodes the specified Http message. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encode + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.rules != null && message.rules.length) + for (var i = 0; i < message.rules.length; ++i) + $root.google.api.HttpRule.encode(message.rules[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.fullyDecodeReservedExpansion != null && Object.hasOwnProperty.call(message, "fullyDecodeReservedExpansion")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.fullyDecodeReservedExpansion); + return writer; + }; + + /** + * Encodes the specified Http message, length delimited. Does not implicitly {@link google.api.Http.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Http + * @static + * @param {google.api.IHttp} message Http message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Http.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Http message from the specified reader or buffer. + * @function decode + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.Http(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.rules && message.rules.length)) + message.rules = []; + message.rules.push($root.google.api.HttpRule.decode(reader, reader.uint32())); + break; + } + case 2: { + message.fullyDecodeReservedExpansion = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Http message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Http + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Http} Http + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Http.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Http message. + * @function verify + * @memberof google.api.Http + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Http.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.rules != null && message.hasOwnProperty("rules")) { + if (!Array.isArray(message.rules)) + return "rules: array expected"; + for (var i = 0; i < message.rules.length; ++i) { + var error = $root.google.api.HttpRule.verify(message.rules[i]); + if (error) + return "rules." + error; + } + } + if (message.fullyDecodeReservedExpansion != null && message.hasOwnProperty("fullyDecodeReservedExpansion")) + if (typeof message.fullyDecodeReservedExpansion !== "boolean") + return "fullyDecodeReservedExpansion: boolean expected"; + return null; + }; + + /** + * Creates a Http message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Http + * @static + * @param {Object.} object Plain object + * @returns {google.api.Http} Http + */ + Http.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Http) + return object; + var message = new $root.google.api.Http(); + if (object.rules) { + if (!Array.isArray(object.rules)) + throw TypeError(".google.api.Http.rules: array expected"); + message.rules = []; + for (var i = 0; i < object.rules.length; ++i) { + if (typeof object.rules[i] !== "object") + throw TypeError(".google.api.Http.rules: object expected"); + message.rules[i] = $root.google.api.HttpRule.fromObject(object.rules[i]); + } + } + if (object.fullyDecodeReservedExpansion != null) + message.fullyDecodeReservedExpansion = Boolean(object.fullyDecodeReservedExpansion); + return message; + }; + + /** + * Creates a plain object from a Http message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Http + * @static + * @param {google.api.Http} message Http + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Http.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.rules = []; + if (options.defaults) + object.fullyDecodeReservedExpansion = false; + if (message.rules && message.rules.length) { + object.rules = []; + for (var j = 0; j < message.rules.length; ++j) + object.rules[j] = $root.google.api.HttpRule.toObject(message.rules[j], options); + } + if (message.fullyDecodeReservedExpansion != null && message.hasOwnProperty("fullyDecodeReservedExpansion")) + object.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion; + return object; + }; + + /** + * Converts this Http to JSON. + * @function toJSON + * @memberof google.api.Http + * @instance + * @returns {Object.} JSON object + */ + Http.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Http + * @function getTypeUrl + * @memberof google.api.Http + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Http.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.Http"; + }; + + return Http; + })(); + + api.HttpRule = (function() { + + /** + * Properties of a HttpRule. + * @memberof google.api + * @interface IHttpRule + * @property {string|null} [selector] HttpRule selector + * @property {string|null} [get] HttpRule get + * @property {string|null} [put] HttpRule put + * @property {string|null} [post] HttpRule post + * @property {string|null} ["delete"] HttpRule delete + * @property {string|null} [patch] HttpRule patch + * @property {google.api.ICustomHttpPattern|null} [custom] HttpRule custom + * @property {string|null} [body] HttpRule body + * @property {string|null} [responseBody] HttpRule responseBody + * @property {Array.|null} [additionalBindings] HttpRule additionalBindings + */ + + /** + * Constructs a new HttpRule. + * @memberof google.api + * @classdesc Represents a HttpRule. + * @implements IHttpRule + * @constructor + * @param {google.api.IHttpRule=} [properties] Properties to set + */ + function HttpRule(properties) { + this.additionalBindings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * HttpRule selector. + * @member {string} selector + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.selector = ""; + + /** + * HttpRule get. + * @member {string|null|undefined} get + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.get = null; + + /** + * HttpRule put. + * @member {string|null|undefined} put + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.put = null; + + /** + * HttpRule post. + * @member {string|null|undefined} post + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.post = null; + + /** + * HttpRule delete. + * @member {string|null|undefined} delete + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype["delete"] = null; + + /** + * HttpRule patch. + * @member {string|null|undefined} patch + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.patch = null; + + /** + * HttpRule custom. + * @member {google.api.ICustomHttpPattern|null|undefined} custom + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.custom = null; + + /** + * HttpRule body. + * @member {string} body + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.body = ""; + + /** + * HttpRule responseBody. + * @member {string} responseBody + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.responseBody = ""; + + /** + * HttpRule additionalBindings. + * @member {Array.} additionalBindings + * @memberof google.api.HttpRule + * @instance + */ + HttpRule.prototype.additionalBindings = $util.emptyArray; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * HttpRule pattern. + * @member {"get"|"put"|"post"|"delete"|"patch"|"custom"|undefined} pattern + * @memberof google.api.HttpRule + * @instance + */ + Object.defineProperty(HttpRule.prototype, "pattern", { + get: $util.oneOfGetter($oneOfFields = ["get", "put", "post", "delete", "patch", "custom"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new HttpRule instance using the specified properties. + * @function create + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule=} [properties] Properties to set + * @returns {google.api.HttpRule} HttpRule instance + */ + HttpRule.create = function create(properties) { + return new HttpRule(properties); + }; + + /** + * Encodes the specified HttpRule message. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encode + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.selector != null && Object.hasOwnProperty.call(message, "selector")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.selector); + if (message.get != null && Object.hasOwnProperty.call(message, "get")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.get); + if (message.put != null && Object.hasOwnProperty.call(message, "put")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.put); + if (message.post != null && Object.hasOwnProperty.call(message, "post")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.post); + if (message["delete"] != null && Object.hasOwnProperty.call(message, "delete")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message["delete"]); + if (message.patch != null && Object.hasOwnProperty.call(message, "patch")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.patch); + if (message.body != null && Object.hasOwnProperty.call(message, "body")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.body); + if (message.custom != null && Object.hasOwnProperty.call(message, "custom")) + $root.google.api.CustomHttpPattern.encode(message.custom, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.additionalBindings != null && message.additionalBindings.length) + for (var i = 0; i < message.additionalBindings.length; ++i) + $root.google.api.HttpRule.encode(message.additionalBindings[i], writer.uint32(/* id 11, wireType 2 =*/90).fork()).ldelim(); + if (message.responseBody != null && Object.hasOwnProperty.call(message, "responseBody")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.responseBody); + return writer; + }; + + /** + * Encodes the specified HttpRule message, length delimited. Does not implicitly {@link google.api.HttpRule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {google.api.IHttpRule} message HttpRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + HttpRule.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a HttpRule message from the specified reader or buffer. + * @function decode + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.HttpRule(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.selector = reader.string(); + break; + } + case 2: { + message.get = reader.string(); + break; + } + case 3: { + message.put = reader.string(); + break; + } + case 4: { + message.post = reader.string(); + break; + } + case 5: { + message["delete"] = reader.string(); + break; + } + case 6: { + message.patch = reader.string(); + break; + } + case 8: { + message.custom = $root.google.api.CustomHttpPattern.decode(reader, reader.uint32()); + break; + } + case 7: { + message.body = reader.string(); + break; + } + case 12: { + message.responseBody = reader.string(); + break; + } + case 11: { + if (!(message.additionalBindings && message.additionalBindings.length)) + message.additionalBindings = []; + message.additionalBindings.push($root.google.api.HttpRule.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a HttpRule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.HttpRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.HttpRule} HttpRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + HttpRule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a HttpRule message. + * @function verify + * @memberof google.api.HttpRule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + HttpRule.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.selector != null && message.hasOwnProperty("selector")) + if (!$util.isString(message.selector)) + return "selector: string expected"; + if (message.get != null && message.hasOwnProperty("get")) { + properties.pattern = 1; + if (!$util.isString(message.get)) + return "get: string expected"; + } + if (message.put != null && message.hasOwnProperty("put")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message.put)) + return "put: string expected"; + } + if (message.post != null && message.hasOwnProperty("post")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message.post)) + return "post: string expected"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message["delete"])) + return "delete: string expected"; + } + if (message.patch != null && message.hasOwnProperty("patch")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + if (!$util.isString(message.patch)) + return "patch: string expected"; + } + if (message.custom != null && message.hasOwnProperty("custom")) { + if (properties.pattern === 1) + return "pattern: multiple values"; + properties.pattern = 1; + { + var error = $root.google.api.CustomHttpPattern.verify(message.custom); + if (error) + return "custom." + error; + } + } + if (message.body != null && message.hasOwnProperty("body")) + if (!$util.isString(message.body)) + return "body: string expected"; + if (message.responseBody != null && message.hasOwnProperty("responseBody")) + if (!$util.isString(message.responseBody)) + return "responseBody: string expected"; + if (message.additionalBindings != null && message.hasOwnProperty("additionalBindings")) { + if (!Array.isArray(message.additionalBindings)) + return "additionalBindings: array expected"; + for (var i = 0; i < message.additionalBindings.length; ++i) { + var error = $root.google.api.HttpRule.verify(message.additionalBindings[i]); + if (error) + return "additionalBindings." + error; + } + } + return null; + }; + + /** + * Creates a HttpRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.HttpRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.HttpRule} HttpRule + */ + HttpRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.HttpRule) + return object; + var message = new $root.google.api.HttpRule(); + if (object.selector != null) + message.selector = String(object.selector); + if (object.get != null) + message.get = String(object.get); + if (object.put != null) + message.put = String(object.put); + if (object.post != null) + message.post = String(object.post); + if (object["delete"] != null) + message["delete"] = String(object["delete"]); + if (object.patch != null) + message.patch = String(object.patch); + if (object.custom != null) { + if (typeof object.custom !== "object") + throw TypeError(".google.api.HttpRule.custom: object expected"); + message.custom = $root.google.api.CustomHttpPattern.fromObject(object.custom); + } + if (object.body != null) + message.body = String(object.body); + if (object.responseBody != null) + message.responseBody = String(object.responseBody); + if (object.additionalBindings) { + if (!Array.isArray(object.additionalBindings)) + throw TypeError(".google.api.HttpRule.additionalBindings: array expected"); + message.additionalBindings = []; + for (var i = 0; i < object.additionalBindings.length; ++i) { + if (typeof object.additionalBindings[i] !== "object") + throw TypeError(".google.api.HttpRule.additionalBindings: object expected"); + message.additionalBindings[i] = $root.google.api.HttpRule.fromObject(object.additionalBindings[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a HttpRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.HttpRule + * @static + * @param {google.api.HttpRule} message HttpRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + HttpRule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.additionalBindings = []; + if (options.defaults) { + object.selector = ""; + object.body = ""; + object.responseBody = ""; + } + if (message.selector != null && message.hasOwnProperty("selector")) + object.selector = message.selector; + if (message.get != null && message.hasOwnProperty("get")) { + object.get = message.get; + if (options.oneofs) + object.pattern = "get"; + } + if (message.put != null && message.hasOwnProperty("put")) { + object.put = message.put; + if (options.oneofs) + object.pattern = "put"; + } + if (message.post != null && message.hasOwnProperty("post")) { + object.post = message.post; + if (options.oneofs) + object.pattern = "post"; + } + if (message["delete"] != null && message.hasOwnProperty("delete")) { + object["delete"] = message["delete"]; + if (options.oneofs) + object.pattern = "delete"; + } + if (message.patch != null && message.hasOwnProperty("patch")) { + object.patch = message.patch; + if (options.oneofs) + object.pattern = "patch"; + } + if (message.body != null && message.hasOwnProperty("body")) + object.body = message.body; + if (message.custom != null && message.hasOwnProperty("custom")) { + object.custom = $root.google.api.CustomHttpPattern.toObject(message.custom, options); + if (options.oneofs) + object.pattern = "custom"; + } + if (message.additionalBindings && message.additionalBindings.length) { + object.additionalBindings = []; + for (var j = 0; j < message.additionalBindings.length; ++j) + object.additionalBindings[j] = $root.google.api.HttpRule.toObject(message.additionalBindings[j], options); + } + if (message.responseBody != null && message.hasOwnProperty("responseBody")) + object.responseBody = message.responseBody; + return object; + }; + + /** + * Converts this HttpRule to JSON. + * @function toJSON + * @memberof google.api.HttpRule + * @instance + * @returns {Object.} JSON object + */ + HttpRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for HttpRule + * @function getTypeUrl + * @memberof google.api.HttpRule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + HttpRule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.HttpRule"; + }; + + return HttpRule; + })(); + + api.CustomHttpPattern = (function() { + + /** + * Properties of a CustomHttpPattern. + * @memberof google.api + * @interface ICustomHttpPattern + * @property {string|null} [kind] CustomHttpPattern kind + * @property {string|null} [path] CustomHttpPattern path + */ + + /** + * Constructs a new CustomHttpPattern. + * @memberof google.api + * @classdesc Represents a CustomHttpPattern. + * @implements ICustomHttpPattern + * @constructor + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + */ + function CustomHttpPattern(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CustomHttpPattern kind. + * @member {string} kind + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.kind = ""; + + /** + * CustomHttpPattern path. + * @member {string} path + * @memberof google.api.CustomHttpPattern + * @instance + */ + CustomHttpPattern.prototype.path = ""; + + /** + * Creates a new CustomHttpPattern instance using the specified properties. + * @function create + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern=} [properties] Properties to set + * @returns {google.api.CustomHttpPattern} CustomHttpPattern instance + */ + CustomHttpPattern.create = function create(properties) { + return new CustomHttpPattern(properties); + }; + + /** + * Encodes the specified CustomHttpPattern message. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encode + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.kind != null && Object.hasOwnProperty.call(message, "kind")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.kind); + if (message.path != null && Object.hasOwnProperty.call(message, "path")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.path); + return writer; + }; + + /** + * Encodes the specified CustomHttpPattern message, length delimited. Does not implicitly {@link google.api.CustomHttpPattern.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.ICustomHttpPattern} message CustomHttpPattern message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CustomHttpPattern.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer. + * @function decode + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.CustomHttpPattern(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.kind = reader.string(); + break; + } + case 2: { + message.path = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CustomHttpPattern message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.CustomHttpPattern + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CustomHttpPattern.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CustomHttpPattern message. + * @function verify + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CustomHttpPattern.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.kind != null && message.hasOwnProperty("kind")) + if (!$util.isString(message.kind)) + return "kind: string expected"; + if (message.path != null && message.hasOwnProperty("path")) + if (!$util.isString(message.path)) + return "path: string expected"; + return null; + }; + + /** + * Creates a CustomHttpPattern message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {Object.} object Plain object + * @returns {google.api.CustomHttpPattern} CustomHttpPattern + */ + CustomHttpPattern.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CustomHttpPattern) + return object; + var message = new $root.google.api.CustomHttpPattern(); + if (object.kind != null) + message.kind = String(object.kind); + if (object.path != null) + message.path = String(object.path); + return message; + }; + + /** + * Creates a plain object from a CustomHttpPattern message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CustomHttpPattern + * @static + * @param {google.api.CustomHttpPattern} message CustomHttpPattern + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CustomHttpPattern.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.kind = ""; + object.path = ""; + } + if (message.kind != null && message.hasOwnProperty("kind")) + object.kind = message.kind; + if (message.path != null && message.hasOwnProperty("path")) + object.path = message.path; + return object; + }; + + /** + * Converts this CustomHttpPattern to JSON. + * @function toJSON + * @memberof google.api.CustomHttpPattern + * @instance + * @returns {Object.} JSON object + */ + CustomHttpPattern.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CustomHttpPattern + * @function getTypeUrl + * @memberof google.api.CustomHttpPattern + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CustomHttpPattern.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.CustomHttpPattern"; + }; + + return CustomHttpPattern; + })(); + + api.CommonLanguageSettings = (function() { + + /** + * Properties of a CommonLanguageSettings. + * @memberof google.api + * @interface ICommonLanguageSettings + * @property {string|null} [referenceDocsUri] CommonLanguageSettings referenceDocsUri + * @property {Array.|null} [destinations] CommonLanguageSettings destinations + * @property {google.api.ISelectiveGapicGeneration|null} [selectiveGapicGeneration] CommonLanguageSettings selectiveGapicGeneration + */ + + /** + * Constructs a new CommonLanguageSettings. + * @memberof google.api + * @classdesc Represents a CommonLanguageSettings. + * @implements ICommonLanguageSettings + * @constructor + * @param {google.api.ICommonLanguageSettings=} [properties] Properties to set + */ + function CommonLanguageSettings(properties) { + this.destinations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CommonLanguageSettings referenceDocsUri. + * @member {string} referenceDocsUri + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.referenceDocsUri = ""; + + /** + * CommonLanguageSettings destinations. + * @member {Array.} destinations + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.destinations = $util.emptyArray; + + /** + * CommonLanguageSettings selectiveGapicGeneration. + * @member {google.api.ISelectiveGapicGeneration|null|undefined} selectiveGapicGeneration + * @memberof google.api.CommonLanguageSettings + * @instance + */ + CommonLanguageSettings.prototype.selectiveGapicGeneration = null; + + /** + * Creates a new CommonLanguageSettings instance using the specified properties. + * @function create + * @memberof google.api.CommonLanguageSettings + * @static + * @param {google.api.ICommonLanguageSettings=} [properties] Properties to set + * @returns {google.api.CommonLanguageSettings} CommonLanguageSettings instance + */ + CommonLanguageSettings.create = function create(properties) { + return new CommonLanguageSettings(properties); + }; + + /** + * Encodes the specified CommonLanguageSettings message. Does not implicitly {@link google.api.CommonLanguageSettings.verify|verify} messages. + * @function encode + * @memberof google.api.CommonLanguageSettings + * @static + * @param {google.api.ICommonLanguageSettings} message CommonLanguageSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommonLanguageSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.referenceDocsUri != null && Object.hasOwnProperty.call(message, "referenceDocsUri")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.referenceDocsUri); + if (message.destinations != null && message.destinations.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.destinations.length; ++i) + writer.int32(message.destinations[i]); + writer.ldelim(); + } + if (message.selectiveGapicGeneration != null && Object.hasOwnProperty.call(message, "selectiveGapicGeneration")) + $root.google.api.SelectiveGapicGeneration.encode(message.selectiveGapicGeneration, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CommonLanguageSettings message, length delimited. Does not implicitly {@link google.api.CommonLanguageSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.CommonLanguageSettings + * @static + * @param {google.api.ICommonLanguageSettings} message CommonLanguageSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CommonLanguageSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CommonLanguageSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.CommonLanguageSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.CommonLanguageSettings} CommonLanguageSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommonLanguageSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.CommonLanguageSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.referenceDocsUri = reader.string(); + break; + } + case 2: { + if (!(message.destinations && message.destinations.length)) + message.destinations = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.destinations.push(reader.int32()); + } else + message.destinations.push(reader.int32()); + break; + } + case 3: { + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CommonLanguageSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.CommonLanguageSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.CommonLanguageSettings} CommonLanguageSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CommonLanguageSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CommonLanguageSettings message. + * @function verify + * @memberof google.api.CommonLanguageSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CommonLanguageSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) + if (!$util.isString(message.referenceDocsUri)) + return "referenceDocsUri: string expected"; + if (message.destinations != null && message.hasOwnProperty("destinations")) { + if (!Array.isArray(message.destinations)) + return "destinations: array expected"; + for (var i = 0; i < message.destinations.length; ++i) + switch (message.destinations[i]) { + default: + return "destinations: enum value[] expected"; + case 0: + case 10: + case 20: + break; + } + } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) { + var error = $root.google.api.SelectiveGapicGeneration.verify(message.selectiveGapicGeneration); + if (error) + return "selectiveGapicGeneration." + error; + } + return null; + }; + + /** + * Creates a CommonLanguageSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CommonLanguageSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.CommonLanguageSettings} CommonLanguageSettings + */ + CommonLanguageSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CommonLanguageSettings) + return object; + var message = new $root.google.api.CommonLanguageSettings(); + if (object.referenceDocsUri != null) + message.referenceDocsUri = String(object.referenceDocsUri); + if (object.destinations) { + if (!Array.isArray(object.destinations)) + throw TypeError(".google.api.CommonLanguageSettings.destinations: array expected"); + message.destinations = []; + for (var i = 0; i < object.destinations.length; ++i) + switch (object.destinations[i]) { + default: + if (typeof object.destinations[i] === "number") { + message.destinations[i] = object.destinations[i]; + break; + } + case "CLIENT_LIBRARY_DESTINATION_UNSPECIFIED": + case 0: + message.destinations[i] = 0; + break; + case "GITHUB": + case 10: + message.destinations[i] = 10; + break; + case "PACKAGE_MANAGER": + case 20: + message.destinations[i] = 20; + break; + } + } + if (object.selectiveGapicGeneration != null) { + if (typeof object.selectiveGapicGeneration !== "object") + throw TypeError(".google.api.CommonLanguageSettings.selectiveGapicGeneration: object expected"); + message.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.fromObject(object.selectiveGapicGeneration); + } + return message; + }; + + /** + * Creates a plain object from a CommonLanguageSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CommonLanguageSettings + * @static + * @param {google.api.CommonLanguageSettings} message CommonLanguageSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CommonLanguageSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.destinations = []; + if (options.defaults) { + object.referenceDocsUri = ""; + object.selectiveGapicGeneration = null; + } + if (message.referenceDocsUri != null && message.hasOwnProperty("referenceDocsUri")) + object.referenceDocsUri = message.referenceDocsUri; + if (message.destinations && message.destinations.length) { + object.destinations = []; + for (var j = 0; j < message.destinations.length; ++j) + object.destinations[j] = options.enums === String ? $root.google.api.ClientLibraryDestination[message.destinations[j]] === undefined ? message.destinations[j] : $root.google.api.ClientLibraryDestination[message.destinations[j]] : message.destinations[j]; + } + if (message.selectiveGapicGeneration != null && message.hasOwnProperty("selectiveGapicGeneration")) + object.selectiveGapicGeneration = $root.google.api.SelectiveGapicGeneration.toObject(message.selectiveGapicGeneration, options); + return object; + }; + + /** + * Converts this CommonLanguageSettings to JSON. + * @function toJSON + * @memberof google.api.CommonLanguageSettings + * @instance + * @returns {Object.} JSON object + */ + CommonLanguageSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CommonLanguageSettings + * @function getTypeUrl + * @memberof google.api.CommonLanguageSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CommonLanguageSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.CommonLanguageSettings"; + }; + + return CommonLanguageSettings; + })(); + + api.ClientLibrarySettings = (function() { + + /** + * Properties of a ClientLibrarySettings. + * @memberof google.api + * @interface IClientLibrarySettings + * @property {string|null} [version] ClientLibrarySettings version + * @property {google.api.LaunchStage|null} [launchStage] ClientLibrarySettings launchStage + * @property {boolean|null} [restNumericEnums] ClientLibrarySettings restNumericEnums + * @property {google.api.IJavaSettings|null} [javaSettings] ClientLibrarySettings javaSettings + * @property {google.api.ICppSettings|null} [cppSettings] ClientLibrarySettings cppSettings + * @property {google.api.IPhpSettings|null} [phpSettings] ClientLibrarySettings phpSettings + * @property {google.api.IPythonSettings|null} [pythonSettings] ClientLibrarySettings pythonSettings + * @property {google.api.INodeSettings|null} [nodeSettings] ClientLibrarySettings nodeSettings + * @property {google.api.IDotnetSettings|null} [dotnetSettings] ClientLibrarySettings dotnetSettings + * @property {google.api.IRubySettings|null} [rubySettings] ClientLibrarySettings rubySettings + * @property {google.api.IGoSettings|null} [goSettings] ClientLibrarySettings goSettings + */ + + /** + * Constructs a new ClientLibrarySettings. + * @memberof google.api + * @classdesc Represents a ClientLibrarySettings. + * @implements IClientLibrarySettings + * @constructor + * @param {google.api.IClientLibrarySettings=} [properties] Properties to set + */ + function ClientLibrarySettings(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ClientLibrarySettings version. + * @member {string} version + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.version = ""; + + /** + * ClientLibrarySettings launchStage. + * @member {google.api.LaunchStage} launchStage + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.launchStage = 0; + + /** + * ClientLibrarySettings restNumericEnums. + * @member {boolean} restNumericEnums + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.restNumericEnums = false; + + /** + * ClientLibrarySettings javaSettings. + * @member {google.api.IJavaSettings|null|undefined} javaSettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.javaSettings = null; + + /** + * ClientLibrarySettings cppSettings. + * @member {google.api.ICppSettings|null|undefined} cppSettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.cppSettings = null; + + /** + * ClientLibrarySettings phpSettings. + * @member {google.api.IPhpSettings|null|undefined} phpSettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.phpSettings = null; + + /** + * ClientLibrarySettings pythonSettings. + * @member {google.api.IPythonSettings|null|undefined} pythonSettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.pythonSettings = null; + + /** + * ClientLibrarySettings nodeSettings. + * @member {google.api.INodeSettings|null|undefined} nodeSettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.nodeSettings = null; + + /** + * ClientLibrarySettings dotnetSettings. + * @member {google.api.IDotnetSettings|null|undefined} dotnetSettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.dotnetSettings = null; + + /** + * ClientLibrarySettings rubySettings. + * @member {google.api.IRubySettings|null|undefined} rubySettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.rubySettings = null; + + /** + * ClientLibrarySettings goSettings. + * @member {google.api.IGoSettings|null|undefined} goSettings + * @memberof google.api.ClientLibrarySettings + * @instance + */ + ClientLibrarySettings.prototype.goSettings = null; + + /** + * Creates a new ClientLibrarySettings instance using the specified properties. + * @function create + * @memberof google.api.ClientLibrarySettings + * @static + * @param {google.api.IClientLibrarySettings=} [properties] Properties to set + * @returns {google.api.ClientLibrarySettings} ClientLibrarySettings instance + */ + ClientLibrarySettings.create = function create(properties) { + return new ClientLibrarySettings(properties); + }; + + /** + * Encodes the specified ClientLibrarySettings message. Does not implicitly {@link google.api.ClientLibrarySettings.verify|verify} messages. + * @function encode + * @memberof google.api.ClientLibrarySettings + * @static + * @param {google.api.IClientLibrarySettings} message ClientLibrarySettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientLibrarySettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.version != null && Object.hasOwnProperty.call(message, "version")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.version); + if (message.launchStage != null && Object.hasOwnProperty.call(message, "launchStage")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.launchStage); + if (message.restNumericEnums != null && Object.hasOwnProperty.call(message, "restNumericEnums")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.restNumericEnums); + if (message.javaSettings != null && Object.hasOwnProperty.call(message, "javaSettings")) + $root.google.api.JavaSettings.encode(message.javaSettings, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.cppSettings != null && Object.hasOwnProperty.call(message, "cppSettings")) + $root.google.api.CppSettings.encode(message.cppSettings, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); + if (message.phpSettings != null && Object.hasOwnProperty.call(message, "phpSettings")) + $root.google.api.PhpSettings.encode(message.phpSettings, writer.uint32(/* id 23, wireType 2 =*/186).fork()).ldelim(); + if (message.pythonSettings != null && Object.hasOwnProperty.call(message, "pythonSettings")) + $root.google.api.PythonSettings.encode(message.pythonSettings, writer.uint32(/* id 24, wireType 2 =*/194).fork()).ldelim(); + if (message.nodeSettings != null && Object.hasOwnProperty.call(message, "nodeSettings")) + $root.google.api.NodeSettings.encode(message.nodeSettings, writer.uint32(/* id 25, wireType 2 =*/202).fork()).ldelim(); + if (message.dotnetSettings != null && Object.hasOwnProperty.call(message, "dotnetSettings")) + $root.google.api.DotnetSettings.encode(message.dotnetSettings, writer.uint32(/* id 26, wireType 2 =*/210).fork()).ldelim(); + if (message.rubySettings != null && Object.hasOwnProperty.call(message, "rubySettings")) + $root.google.api.RubySettings.encode(message.rubySettings, writer.uint32(/* id 27, wireType 2 =*/218).fork()).ldelim(); + if (message.goSettings != null && Object.hasOwnProperty.call(message, "goSettings")) + $root.google.api.GoSettings.encode(message.goSettings, writer.uint32(/* id 28, wireType 2 =*/226).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ClientLibrarySettings message, length delimited. Does not implicitly {@link google.api.ClientLibrarySettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.ClientLibrarySettings + * @static + * @param {google.api.IClientLibrarySettings} message ClientLibrarySettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ClientLibrarySettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ClientLibrarySettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.ClientLibrarySettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.ClientLibrarySettings} ClientLibrarySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientLibrarySettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.ClientLibrarySettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.version = reader.string(); + break; + } + case 2: { + message.launchStage = reader.int32(); + break; + } + case 3: { + message.restNumericEnums = reader.bool(); + break; + } + case 21: { + message.javaSettings = $root.google.api.JavaSettings.decode(reader, reader.uint32()); + break; + } + case 22: { + message.cppSettings = $root.google.api.CppSettings.decode(reader, reader.uint32()); + break; + } + case 23: { + message.phpSettings = $root.google.api.PhpSettings.decode(reader, reader.uint32()); + break; + } + case 24: { + message.pythonSettings = $root.google.api.PythonSettings.decode(reader, reader.uint32()); + break; + } + case 25: { + message.nodeSettings = $root.google.api.NodeSettings.decode(reader, reader.uint32()); + break; + } + case 26: { + message.dotnetSettings = $root.google.api.DotnetSettings.decode(reader, reader.uint32()); + break; + } + case 27: { + message.rubySettings = $root.google.api.RubySettings.decode(reader, reader.uint32()); + break; + } + case 28: { + message.goSettings = $root.google.api.GoSettings.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ClientLibrarySettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.ClientLibrarySettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.ClientLibrarySettings} ClientLibrarySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ClientLibrarySettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ClientLibrarySettings message. + * @function verify + * @memberof google.api.ClientLibrarySettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ClientLibrarySettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.version != null && message.hasOwnProperty("version")) + if (!$util.isString(message.version)) + return "version: string expected"; + if (message.launchStage != null && message.hasOwnProperty("launchStage")) + switch (message.launchStage) { + default: + return "launchStage: enum value expected"; + case 0: + case 6: + case 7: + case 1: + case 2: + case 3: + case 4: + case 5: + break; + } + if (message.restNumericEnums != null && message.hasOwnProperty("restNumericEnums")) + if (typeof message.restNumericEnums !== "boolean") + return "restNumericEnums: boolean expected"; + if (message.javaSettings != null && message.hasOwnProperty("javaSettings")) { + var error = $root.google.api.JavaSettings.verify(message.javaSettings); + if (error) + return "javaSettings." + error; + } + if (message.cppSettings != null && message.hasOwnProperty("cppSettings")) { + var error = $root.google.api.CppSettings.verify(message.cppSettings); + if (error) + return "cppSettings." + error; + } + if (message.phpSettings != null && message.hasOwnProperty("phpSettings")) { + var error = $root.google.api.PhpSettings.verify(message.phpSettings); + if (error) + return "phpSettings." + error; + } + if (message.pythonSettings != null && message.hasOwnProperty("pythonSettings")) { + var error = $root.google.api.PythonSettings.verify(message.pythonSettings); + if (error) + return "pythonSettings." + error; + } + if (message.nodeSettings != null && message.hasOwnProperty("nodeSettings")) { + var error = $root.google.api.NodeSettings.verify(message.nodeSettings); + if (error) + return "nodeSettings." + error; + } + if (message.dotnetSettings != null && message.hasOwnProperty("dotnetSettings")) { + var error = $root.google.api.DotnetSettings.verify(message.dotnetSettings); + if (error) + return "dotnetSettings." + error; + } + if (message.rubySettings != null && message.hasOwnProperty("rubySettings")) { + var error = $root.google.api.RubySettings.verify(message.rubySettings); + if (error) + return "rubySettings." + error; + } + if (message.goSettings != null && message.hasOwnProperty("goSettings")) { + var error = $root.google.api.GoSettings.verify(message.goSettings); + if (error) + return "goSettings." + error; + } + return null; + }; + + /** + * Creates a ClientLibrarySettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.ClientLibrarySettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.ClientLibrarySettings} ClientLibrarySettings + */ + ClientLibrarySettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.ClientLibrarySettings) + return object; + var message = new $root.google.api.ClientLibrarySettings(); + if (object.version != null) + message.version = String(object.version); + switch (object.launchStage) { + default: + if (typeof object.launchStage === "number") { + message.launchStage = object.launchStage; + break; + } + break; + case "LAUNCH_STAGE_UNSPECIFIED": + case 0: + message.launchStage = 0; + break; + case "UNIMPLEMENTED": + case 6: + message.launchStage = 6; + break; + case "PRELAUNCH": + case 7: + message.launchStage = 7; + break; + case "EARLY_ACCESS": + case 1: + message.launchStage = 1; + break; + case "ALPHA": + case 2: + message.launchStage = 2; + break; + case "BETA": + case 3: + message.launchStage = 3; + break; + case "GA": + case 4: + message.launchStage = 4; + break; + case "DEPRECATED": + case 5: + message.launchStage = 5; + break; + } + if (object.restNumericEnums != null) + message.restNumericEnums = Boolean(object.restNumericEnums); + if (object.javaSettings != null) { + if (typeof object.javaSettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.javaSettings: object expected"); + message.javaSettings = $root.google.api.JavaSettings.fromObject(object.javaSettings); + } + if (object.cppSettings != null) { + if (typeof object.cppSettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.cppSettings: object expected"); + message.cppSettings = $root.google.api.CppSettings.fromObject(object.cppSettings); + } + if (object.phpSettings != null) { + if (typeof object.phpSettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.phpSettings: object expected"); + message.phpSettings = $root.google.api.PhpSettings.fromObject(object.phpSettings); + } + if (object.pythonSettings != null) { + if (typeof object.pythonSettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.pythonSettings: object expected"); + message.pythonSettings = $root.google.api.PythonSettings.fromObject(object.pythonSettings); + } + if (object.nodeSettings != null) { + if (typeof object.nodeSettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.nodeSettings: object expected"); + message.nodeSettings = $root.google.api.NodeSettings.fromObject(object.nodeSettings); + } + if (object.dotnetSettings != null) { + if (typeof object.dotnetSettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.dotnetSettings: object expected"); + message.dotnetSettings = $root.google.api.DotnetSettings.fromObject(object.dotnetSettings); + } + if (object.rubySettings != null) { + if (typeof object.rubySettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.rubySettings: object expected"); + message.rubySettings = $root.google.api.RubySettings.fromObject(object.rubySettings); + } + if (object.goSettings != null) { + if (typeof object.goSettings !== "object") + throw TypeError(".google.api.ClientLibrarySettings.goSettings: object expected"); + message.goSettings = $root.google.api.GoSettings.fromObject(object.goSettings); + } + return message; + }; + + /** + * Creates a plain object from a ClientLibrarySettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.ClientLibrarySettings + * @static + * @param {google.api.ClientLibrarySettings} message ClientLibrarySettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ClientLibrarySettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.version = ""; + object.launchStage = options.enums === String ? "LAUNCH_STAGE_UNSPECIFIED" : 0; + object.restNumericEnums = false; + object.javaSettings = null; + object.cppSettings = null; + object.phpSettings = null; + object.pythonSettings = null; + object.nodeSettings = null; + object.dotnetSettings = null; + object.rubySettings = null; + object.goSettings = null; + } + if (message.version != null && message.hasOwnProperty("version")) + object.version = message.version; + if (message.launchStage != null && message.hasOwnProperty("launchStage")) + object.launchStage = options.enums === String ? $root.google.api.LaunchStage[message.launchStage] === undefined ? message.launchStage : $root.google.api.LaunchStage[message.launchStage] : message.launchStage; + if (message.restNumericEnums != null && message.hasOwnProperty("restNumericEnums")) + object.restNumericEnums = message.restNumericEnums; + if (message.javaSettings != null && message.hasOwnProperty("javaSettings")) + object.javaSettings = $root.google.api.JavaSettings.toObject(message.javaSettings, options); + if (message.cppSettings != null && message.hasOwnProperty("cppSettings")) + object.cppSettings = $root.google.api.CppSettings.toObject(message.cppSettings, options); + if (message.phpSettings != null && message.hasOwnProperty("phpSettings")) + object.phpSettings = $root.google.api.PhpSettings.toObject(message.phpSettings, options); + if (message.pythonSettings != null && message.hasOwnProperty("pythonSettings")) + object.pythonSettings = $root.google.api.PythonSettings.toObject(message.pythonSettings, options); + if (message.nodeSettings != null && message.hasOwnProperty("nodeSettings")) + object.nodeSettings = $root.google.api.NodeSettings.toObject(message.nodeSettings, options); + if (message.dotnetSettings != null && message.hasOwnProperty("dotnetSettings")) + object.dotnetSettings = $root.google.api.DotnetSettings.toObject(message.dotnetSettings, options); + if (message.rubySettings != null && message.hasOwnProperty("rubySettings")) + object.rubySettings = $root.google.api.RubySettings.toObject(message.rubySettings, options); + if (message.goSettings != null && message.hasOwnProperty("goSettings")) + object.goSettings = $root.google.api.GoSettings.toObject(message.goSettings, options); + return object; + }; + + /** + * Converts this ClientLibrarySettings to JSON. + * @function toJSON + * @memberof google.api.ClientLibrarySettings + * @instance + * @returns {Object.} JSON object + */ + ClientLibrarySettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ClientLibrarySettings + * @function getTypeUrl + * @memberof google.api.ClientLibrarySettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ClientLibrarySettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.ClientLibrarySettings"; + }; + + return ClientLibrarySettings; + })(); + + api.Publishing = (function() { + + /** + * Properties of a Publishing. + * @memberof google.api + * @interface IPublishing + * @property {Array.|null} [methodSettings] Publishing methodSettings + * @property {string|null} [newIssueUri] Publishing newIssueUri + * @property {string|null} [documentationUri] Publishing documentationUri + * @property {string|null} [apiShortName] Publishing apiShortName + * @property {string|null} [githubLabel] Publishing githubLabel + * @property {Array.|null} [codeownerGithubTeams] Publishing codeownerGithubTeams + * @property {string|null} [docTagPrefix] Publishing docTagPrefix + * @property {google.api.ClientLibraryOrganization|null} [organization] Publishing organization + * @property {Array.|null} [librarySettings] Publishing librarySettings + * @property {string|null} [protoReferenceDocumentationUri] Publishing protoReferenceDocumentationUri + * @property {string|null} [restReferenceDocumentationUri] Publishing restReferenceDocumentationUri + */ + + /** + * Constructs a new Publishing. + * @memberof google.api + * @classdesc Represents a Publishing. + * @implements IPublishing + * @constructor + * @param {google.api.IPublishing=} [properties] Properties to set + */ + function Publishing(properties) { + this.methodSettings = []; + this.codeownerGithubTeams = []; + this.librarySettings = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Publishing methodSettings. + * @member {Array.} methodSettings + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.methodSettings = $util.emptyArray; + + /** + * Publishing newIssueUri. + * @member {string} newIssueUri + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.newIssueUri = ""; + + /** + * Publishing documentationUri. + * @member {string} documentationUri + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.documentationUri = ""; + + /** + * Publishing apiShortName. + * @member {string} apiShortName + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.apiShortName = ""; + + /** + * Publishing githubLabel. + * @member {string} githubLabel + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.githubLabel = ""; + + /** + * Publishing codeownerGithubTeams. + * @member {Array.} codeownerGithubTeams + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.codeownerGithubTeams = $util.emptyArray; + + /** + * Publishing docTagPrefix. + * @member {string} docTagPrefix + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.docTagPrefix = ""; + + /** + * Publishing organization. + * @member {google.api.ClientLibraryOrganization} organization + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.organization = 0; + + /** + * Publishing librarySettings. + * @member {Array.} librarySettings + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.librarySettings = $util.emptyArray; + + /** + * Publishing protoReferenceDocumentationUri. + * @member {string} protoReferenceDocumentationUri + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.protoReferenceDocumentationUri = ""; + + /** + * Publishing restReferenceDocumentationUri. + * @member {string} restReferenceDocumentationUri + * @memberof google.api.Publishing + * @instance + */ + Publishing.prototype.restReferenceDocumentationUri = ""; + + /** + * Creates a new Publishing instance using the specified properties. + * @function create + * @memberof google.api.Publishing + * @static + * @param {google.api.IPublishing=} [properties] Properties to set + * @returns {google.api.Publishing} Publishing instance + */ + Publishing.create = function create(properties) { + return new Publishing(properties); + }; + + /** + * Encodes the specified Publishing message. Does not implicitly {@link google.api.Publishing.verify|verify} messages. + * @function encode + * @memberof google.api.Publishing + * @static + * @param {google.api.IPublishing} message Publishing message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Publishing.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methodSettings != null && message.methodSettings.length) + for (var i = 0; i < message.methodSettings.length; ++i) + $root.google.api.MethodSettings.encode(message.methodSettings[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.newIssueUri != null && Object.hasOwnProperty.call(message, "newIssueUri")) + writer.uint32(/* id 101, wireType 2 =*/810).string(message.newIssueUri); + if (message.documentationUri != null && Object.hasOwnProperty.call(message, "documentationUri")) + writer.uint32(/* id 102, wireType 2 =*/818).string(message.documentationUri); + if (message.apiShortName != null && Object.hasOwnProperty.call(message, "apiShortName")) + writer.uint32(/* id 103, wireType 2 =*/826).string(message.apiShortName); + if (message.githubLabel != null && Object.hasOwnProperty.call(message, "githubLabel")) + writer.uint32(/* id 104, wireType 2 =*/834).string(message.githubLabel); + if (message.codeownerGithubTeams != null && message.codeownerGithubTeams.length) + for (var i = 0; i < message.codeownerGithubTeams.length; ++i) + writer.uint32(/* id 105, wireType 2 =*/842).string(message.codeownerGithubTeams[i]); + if (message.docTagPrefix != null && Object.hasOwnProperty.call(message, "docTagPrefix")) + writer.uint32(/* id 106, wireType 2 =*/850).string(message.docTagPrefix); + if (message.organization != null && Object.hasOwnProperty.call(message, "organization")) + writer.uint32(/* id 107, wireType 0 =*/856).int32(message.organization); + if (message.librarySettings != null && message.librarySettings.length) + for (var i = 0; i < message.librarySettings.length; ++i) + $root.google.api.ClientLibrarySettings.encode(message.librarySettings[i], writer.uint32(/* id 109, wireType 2 =*/874).fork()).ldelim(); + if (message.protoReferenceDocumentationUri != null && Object.hasOwnProperty.call(message, "protoReferenceDocumentationUri")) + writer.uint32(/* id 110, wireType 2 =*/882).string(message.protoReferenceDocumentationUri); + if (message.restReferenceDocumentationUri != null && Object.hasOwnProperty.call(message, "restReferenceDocumentationUri")) + writer.uint32(/* id 111, wireType 2 =*/890).string(message.restReferenceDocumentationUri); + return writer; + }; + + /** + * Encodes the specified Publishing message, length delimited. Does not implicitly {@link google.api.Publishing.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.Publishing + * @static + * @param {google.api.IPublishing} message Publishing message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Publishing.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Publishing message from the specified reader or buffer. + * @function decode + * @memberof google.api.Publishing + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.Publishing} Publishing + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Publishing.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.Publishing(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.methodSettings && message.methodSettings.length)) + message.methodSettings = []; + message.methodSettings.push($root.google.api.MethodSettings.decode(reader, reader.uint32())); + break; + } + case 101: { + message.newIssueUri = reader.string(); + break; + } + case 102: { + message.documentationUri = reader.string(); + break; + } + case 103: { + message.apiShortName = reader.string(); + break; + } + case 104: { + message.githubLabel = reader.string(); + break; + } + case 105: { + if (!(message.codeownerGithubTeams && message.codeownerGithubTeams.length)) + message.codeownerGithubTeams = []; + message.codeownerGithubTeams.push(reader.string()); + break; + } + case 106: { + message.docTagPrefix = reader.string(); + break; + } + case 107: { + message.organization = reader.int32(); + break; + } + case 109: { + if (!(message.librarySettings && message.librarySettings.length)) + message.librarySettings = []; + message.librarySettings.push($root.google.api.ClientLibrarySettings.decode(reader, reader.uint32())); + break; + } + case 110: { + message.protoReferenceDocumentationUri = reader.string(); + break; + } + case 111: { + message.restReferenceDocumentationUri = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Publishing message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.Publishing + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.Publishing} Publishing + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Publishing.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Publishing message. + * @function verify + * @memberof google.api.Publishing + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Publishing.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methodSettings != null && message.hasOwnProperty("methodSettings")) { + if (!Array.isArray(message.methodSettings)) + return "methodSettings: array expected"; + for (var i = 0; i < message.methodSettings.length; ++i) { + var error = $root.google.api.MethodSettings.verify(message.methodSettings[i]); + if (error) + return "methodSettings." + error; + } + } + if (message.newIssueUri != null && message.hasOwnProperty("newIssueUri")) + if (!$util.isString(message.newIssueUri)) + return "newIssueUri: string expected"; + if (message.documentationUri != null && message.hasOwnProperty("documentationUri")) + if (!$util.isString(message.documentationUri)) + return "documentationUri: string expected"; + if (message.apiShortName != null && message.hasOwnProperty("apiShortName")) + if (!$util.isString(message.apiShortName)) + return "apiShortName: string expected"; + if (message.githubLabel != null && message.hasOwnProperty("githubLabel")) + if (!$util.isString(message.githubLabel)) + return "githubLabel: string expected"; + if (message.codeownerGithubTeams != null && message.hasOwnProperty("codeownerGithubTeams")) { + if (!Array.isArray(message.codeownerGithubTeams)) + return "codeownerGithubTeams: array expected"; + for (var i = 0; i < message.codeownerGithubTeams.length; ++i) + if (!$util.isString(message.codeownerGithubTeams[i])) + return "codeownerGithubTeams: string[] expected"; + } + if (message.docTagPrefix != null && message.hasOwnProperty("docTagPrefix")) + if (!$util.isString(message.docTagPrefix)) + return "docTagPrefix: string expected"; + if (message.organization != null && message.hasOwnProperty("organization")) + switch (message.organization) { + default: + return "organization: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + break; + } + if (message.librarySettings != null && message.hasOwnProperty("librarySettings")) { + if (!Array.isArray(message.librarySettings)) + return "librarySettings: array expected"; + for (var i = 0; i < message.librarySettings.length; ++i) { + var error = $root.google.api.ClientLibrarySettings.verify(message.librarySettings[i]); + if (error) + return "librarySettings." + error; + } + } + if (message.protoReferenceDocumentationUri != null && message.hasOwnProperty("protoReferenceDocumentationUri")) + if (!$util.isString(message.protoReferenceDocumentationUri)) + return "protoReferenceDocumentationUri: string expected"; + if (message.restReferenceDocumentationUri != null && message.hasOwnProperty("restReferenceDocumentationUri")) + if (!$util.isString(message.restReferenceDocumentationUri)) + return "restReferenceDocumentationUri: string expected"; + return null; + }; + + /** + * Creates a Publishing message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.Publishing + * @static + * @param {Object.} object Plain object + * @returns {google.api.Publishing} Publishing + */ + Publishing.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.Publishing) + return object; + var message = new $root.google.api.Publishing(); + if (object.methodSettings) { + if (!Array.isArray(object.methodSettings)) + throw TypeError(".google.api.Publishing.methodSettings: array expected"); + message.methodSettings = []; + for (var i = 0; i < object.methodSettings.length; ++i) { + if (typeof object.methodSettings[i] !== "object") + throw TypeError(".google.api.Publishing.methodSettings: object expected"); + message.methodSettings[i] = $root.google.api.MethodSettings.fromObject(object.methodSettings[i]); + } + } + if (object.newIssueUri != null) + message.newIssueUri = String(object.newIssueUri); + if (object.documentationUri != null) + message.documentationUri = String(object.documentationUri); + if (object.apiShortName != null) + message.apiShortName = String(object.apiShortName); + if (object.githubLabel != null) + message.githubLabel = String(object.githubLabel); + if (object.codeownerGithubTeams) { + if (!Array.isArray(object.codeownerGithubTeams)) + throw TypeError(".google.api.Publishing.codeownerGithubTeams: array expected"); + message.codeownerGithubTeams = []; + for (var i = 0; i < object.codeownerGithubTeams.length; ++i) + message.codeownerGithubTeams[i] = String(object.codeownerGithubTeams[i]); + } + if (object.docTagPrefix != null) + message.docTagPrefix = String(object.docTagPrefix); + switch (object.organization) { + default: + if (typeof object.organization === "number") { + message.organization = object.organization; + break; + } + break; + case "CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED": + case 0: + message.organization = 0; + break; + case "CLOUD": + case 1: + message.organization = 1; + break; + case "ADS": + case 2: + message.organization = 2; + break; + case "PHOTOS": + case 3: + message.organization = 3; + break; + case "STREET_VIEW": + case 4: + message.organization = 4; + break; + case "SHOPPING": + case 5: + message.organization = 5; + break; + case "GEO": + case 6: + message.organization = 6; + break; + case "GENERATIVE_AI": + case 7: + message.organization = 7; + break; + } + if (object.librarySettings) { + if (!Array.isArray(object.librarySettings)) + throw TypeError(".google.api.Publishing.librarySettings: array expected"); + message.librarySettings = []; + for (var i = 0; i < object.librarySettings.length; ++i) { + if (typeof object.librarySettings[i] !== "object") + throw TypeError(".google.api.Publishing.librarySettings: object expected"); + message.librarySettings[i] = $root.google.api.ClientLibrarySettings.fromObject(object.librarySettings[i]); + } + } + if (object.protoReferenceDocumentationUri != null) + message.protoReferenceDocumentationUri = String(object.protoReferenceDocumentationUri); + if (object.restReferenceDocumentationUri != null) + message.restReferenceDocumentationUri = String(object.restReferenceDocumentationUri); + return message; + }; + + /** + * Creates a plain object from a Publishing message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.Publishing + * @static + * @param {google.api.Publishing} message Publishing + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Publishing.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.methodSettings = []; + object.codeownerGithubTeams = []; + object.librarySettings = []; + } + if (options.defaults) { + object.newIssueUri = ""; + object.documentationUri = ""; + object.apiShortName = ""; + object.githubLabel = ""; + object.docTagPrefix = ""; + object.organization = options.enums === String ? "CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED" : 0; + object.protoReferenceDocumentationUri = ""; + object.restReferenceDocumentationUri = ""; + } + if (message.methodSettings && message.methodSettings.length) { + object.methodSettings = []; + for (var j = 0; j < message.methodSettings.length; ++j) + object.methodSettings[j] = $root.google.api.MethodSettings.toObject(message.methodSettings[j], options); + } + if (message.newIssueUri != null && message.hasOwnProperty("newIssueUri")) + object.newIssueUri = message.newIssueUri; + if (message.documentationUri != null && message.hasOwnProperty("documentationUri")) + object.documentationUri = message.documentationUri; + if (message.apiShortName != null && message.hasOwnProperty("apiShortName")) + object.apiShortName = message.apiShortName; + if (message.githubLabel != null && message.hasOwnProperty("githubLabel")) + object.githubLabel = message.githubLabel; + if (message.codeownerGithubTeams && message.codeownerGithubTeams.length) { + object.codeownerGithubTeams = []; + for (var j = 0; j < message.codeownerGithubTeams.length; ++j) + object.codeownerGithubTeams[j] = message.codeownerGithubTeams[j]; + } + if (message.docTagPrefix != null && message.hasOwnProperty("docTagPrefix")) + object.docTagPrefix = message.docTagPrefix; + if (message.organization != null && message.hasOwnProperty("organization")) + object.organization = options.enums === String ? $root.google.api.ClientLibraryOrganization[message.organization] === undefined ? message.organization : $root.google.api.ClientLibraryOrganization[message.organization] : message.organization; + if (message.librarySettings && message.librarySettings.length) { + object.librarySettings = []; + for (var j = 0; j < message.librarySettings.length; ++j) + object.librarySettings[j] = $root.google.api.ClientLibrarySettings.toObject(message.librarySettings[j], options); + } + if (message.protoReferenceDocumentationUri != null && message.hasOwnProperty("protoReferenceDocumentationUri")) + object.protoReferenceDocumentationUri = message.protoReferenceDocumentationUri; + if (message.restReferenceDocumentationUri != null && message.hasOwnProperty("restReferenceDocumentationUri")) + object.restReferenceDocumentationUri = message.restReferenceDocumentationUri; + return object; + }; + + /** + * Converts this Publishing to JSON. + * @function toJSON + * @memberof google.api.Publishing + * @instance + * @returns {Object.} JSON object + */ + Publishing.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Publishing + * @function getTypeUrl + * @memberof google.api.Publishing + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Publishing.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.Publishing"; + }; + + return Publishing; + })(); + + api.JavaSettings = (function() { + + /** + * Properties of a JavaSettings. + * @memberof google.api + * @interface IJavaSettings + * @property {string|null} [libraryPackage] JavaSettings libraryPackage + * @property {Object.|null} [serviceClassNames] JavaSettings serviceClassNames + * @property {google.api.ICommonLanguageSettings|null} [common] JavaSettings common + */ + + /** + * Constructs a new JavaSettings. + * @memberof google.api + * @classdesc Represents a JavaSettings. + * @implements IJavaSettings + * @constructor + * @param {google.api.IJavaSettings=} [properties] Properties to set + */ + function JavaSettings(properties) { + this.serviceClassNames = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * JavaSettings libraryPackage. + * @member {string} libraryPackage + * @memberof google.api.JavaSettings + * @instance + */ + JavaSettings.prototype.libraryPackage = ""; + + /** + * JavaSettings serviceClassNames. + * @member {Object.} serviceClassNames + * @memberof google.api.JavaSettings + * @instance + */ + JavaSettings.prototype.serviceClassNames = $util.emptyObject; + + /** + * JavaSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.JavaSettings + * @instance + */ + JavaSettings.prototype.common = null; + + /** + * Creates a new JavaSettings instance using the specified properties. + * @function create + * @memberof google.api.JavaSettings + * @static + * @param {google.api.IJavaSettings=} [properties] Properties to set + * @returns {google.api.JavaSettings} JavaSettings instance + */ + JavaSettings.create = function create(properties) { + return new JavaSettings(properties); + }; + + /** + * Encodes the specified JavaSettings message. Does not implicitly {@link google.api.JavaSettings.verify|verify} messages. + * @function encode + * @memberof google.api.JavaSettings + * @static + * @param {google.api.IJavaSettings} message JavaSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + JavaSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.libraryPackage != null && Object.hasOwnProperty.call(message, "libraryPackage")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.libraryPackage); + if (message.serviceClassNames != null && Object.hasOwnProperty.call(message, "serviceClassNames")) + for (var keys = Object.keys(message.serviceClassNames), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.serviceClassNames[keys[i]]).ldelim(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified JavaSettings message, length delimited. Does not implicitly {@link google.api.JavaSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.JavaSettings + * @static + * @param {google.api.IJavaSettings} message JavaSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + JavaSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a JavaSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.JavaSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.JavaSettings} JavaSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + JavaSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.JavaSettings(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.libraryPackage = reader.string(); + break; + } + case 2: { + if (message.serviceClassNames === $util.emptyObject) + message.serviceClassNames = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.serviceClassNames[key] = value; + break; + } + case 3: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a JavaSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.JavaSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.JavaSettings} JavaSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + JavaSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a JavaSettings message. + * @function verify + * @memberof google.api.JavaSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + JavaSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.libraryPackage != null && message.hasOwnProperty("libraryPackage")) + if (!$util.isString(message.libraryPackage)) + return "libraryPackage: string expected"; + if (message.serviceClassNames != null && message.hasOwnProperty("serviceClassNames")) { + if (!$util.isObject(message.serviceClassNames)) + return "serviceClassNames: object expected"; + var key = Object.keys(message.serviceClassNames); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.serviceClassNames[key[i]])) + return "serviceClassNames: string{k:string} expected"; + } + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + return null; + }; + + /** + * Creates a JavaSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.JavaSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.JavaSettings} JavaSettings + */ + JavaSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.JavaSettings) + return object; + var message = new $root.google.api.JavaSettings(); + if (object.libraryPackage != null) + message.libraryPackage = String(object.libraryPackage); + if (object.serviceClassNames) { + if (typeof object.serviceClassNames !== "object") + throw TypeError(".google.api.JavaSettings.serviceClassNames: object expected"); + message.serviceClassNames = {}; + for (var keys = Object.keys(object.serviceClassNames), i = 0; i < keys.length; ++i) + message.serviceClassNames[keys[i]] = String(object.serviceClassNames[keys[i]]); + } + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.JavaSettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + return message; + }; + + /** + * Creates a plain object from a JavaSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.JavaSettings + * @static + * @param {google.api.JavaSettings} message JavaSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + JavaSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.serviceClassNames = {}; + if (options.defaults) { + object.libraryPackage = ""; + object.common = null; + } + if (message.libraryPackage != null && message.hasOwnProperty("libraryPackage")) + object.libraryPackage = message.libraryPackage; + var keys2; + if (message.serviceClassNames && (keys2 = Object.keys(message.serviceClassNames)).length) { + object.serviceClassNames = {}; + for (var j = 0; j < keys2.length; ++j) + object.serviceClassNames[keys2[j]] = message.serviceClassNames[keys2[j]]; + } + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + return object; + }; + + /** + * Converts this JavaSettings to JSON. + * @function toJSON + * @memberof google.api.JavaSettings + * @instance + * @returns {Object.} JSON object + */ + JavaSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for JavaSettings + * @function getTypeUrl + * @memberof google.api.JavaSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + JavaSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.JavaSettings"; + }; + + return JavaSettings; + })(); + + api.CppSettings = (function() { + + /** + * Properties of a CppSettings. + * @memberof google.api + * @interface ICppSettings + * @property {google.api.ICommonLanguageSettings|null} [common] CppSettings common + */ + + /** + * Constructs a new CppSettings. + * @memberof google.api + * @classdesc Represents a CppSettings. + * @implements ICppSettings + * @constructor + * @param {google.api.ICppSettings=} [properties] Properties to set + */ + function CppSettings(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CppSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.CppSettings + * @instance + */ + CppSettings.prototype.common = null; + + /** + * Creates a new CppSettings instance using the specified properties. + * @function create + * @memberof google.api.CppSettings + * @static + * @param {google.api.ICppSettings=} [properties] Properties to set + * @returns {google.api.CppSettings} CppSettings instance + */ + CppSettings.create = function create(properties) { + return new CppSettings(properties); + }; + + /** + * Encodes the specified CppSettings message. Does not implicitly {@link google.api.CppSettings.verify|verify} messages. + * @function encode + * @memberof google.api.CppSettings + * @static + * @param {google.api.ICppSettings} message CppSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CppSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CppSettings message, length delimited. Does not implicitly {@link google.api.CppSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.CppSettings + * @static + * @param {google.api.ICppSettings} message CppSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CppSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CppSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.CppSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.CppSettings} CppSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CppSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.CppSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CppSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.CppSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.CppSettings} CppSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CppSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CppSettings message. + * @function verify + * @memberof google.api.CppSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CppSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + return null; + }; + + /** + * Creates a CppSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.CppSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.CppSettings} CppSettings + */ + CppSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.CppSettings) + return object; + var message = new $root.google.api.CppSettings(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.CppSettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + return message; + }; + + /** + * Creates a plain object from a CppSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.CppSettings + * @static + * @param {google.api.CppSettings} message CppSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CppSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.common = null; + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + return object; + }; + + /** + * Converts this CppSettings to JSON. + * @function toJSON + * @memberof google.api.CppSettings + * @instance + * @returns {Object.} JSON object + */ + CppSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CppSettings + * @function getTypeUrl + * @memberof google.api.CppSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CppSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.CppSettings"; + }; + + return CppSettings; + })(); + + api.PhpSettings = (function() { + + /** + * Properties of a PhpSettings. + * @memberof google.api + * @interface IPhpSettings + * @property {google.api.ICommonLanguageSettings|null} [common] PhpSettings common + */ + + /** + * Constructs a new PhpSettings. + * @memberof google.api + * @classdesc Represents a PhpSettings. + * @implements IPhpSettings + * @constructor + * @param {google.api.IPhpSettings=} [properties] Properties to set + */ + function PhpSettings(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PhpSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.PhpSettings + * @instance + */ + PhpSettings.prototype.common = null; + + /** + * Creates a new PhpSettings instance using the specified properties. + * @function create + * @memberof google.api.PhpSettings + * @static + * @param {google.api.IPhpSettings=} [properties] Properties to set + * @returns {google.api.PhpSettings} PhpSettings instance + */ + PhpSettings.create = function create(properties) { + return new PhpSettings(properties); + }; + + /** + * Encodes the specified PhpSettings message. Does not implicitly {@link google.api.PhpSettings.verify|verify} messages. + * @function encode + * @memberof google.api.PhpSettings + * @static + * @param {google.api.IPhpSettings} message PhpSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PhpSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PhpSettings message, length delimited. Does not implicitly {@link google.api.PhpSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PhpSettings + * @static + * @param {google.api.IPhpSettings} message PhpSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PhpSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PhpSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.PhpSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PhpSettings} PhpSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PhpSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PhpSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PhpSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PhpSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PhpSettings} PhpSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PhpSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PhpSettings message. + * @function verify + * @memberof google.api.PhpSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PhpSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + return null; + }; + + /** + * Creates a PhpSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PhpSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.PhpSettings} PhpSettings + */ + PhpSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PhpSettings) + return object; + var message = new $root.google.api.PhpSettings(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.PhpSettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + return message; + }; + + /** + * Creates a plain object from a PhpSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PhpSettings + * @static + * @param {google.api.PhpSettings} message PhpSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PhpSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.common = null; + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + return object; + }; + + /** + * Converts this PhpSettings to JSON. + * @function toJSON + * @memberof google.api.PhpSettings + * @instance + * @returns {Object.} JSON object + */ + PhpSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PhpSettings + * @function getTypeUrl + * @memberof google.api.PhpSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PhpSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PhpSettings"; + }; + + return PhpSettings; + })(); + + api.PythonSettings = (function() { + + /** + * Properties of a PythonSettings. + * @memberof google.api + * @interface IPythonSettings + * @property {google.api.ICommonLanguageSettings|null} [common] PythonSettings common + * @property {google.api.PythonSettings.IExperimentalFeatures|null} [experimentalFeatures] PythonSettings experimentalFeatures + */ + + /** + * Constructs a new PythonSettings. + * @memberof google.api + * @classdesc Represents a PythonSettings. + * @implements IPythonSettings + * @constructor + * @param {google.api.IPythonSettings=} [properties] Properties to set + */ + function PythonSettings(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * PythonSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.common = null; + + /** + * PythonSettings experimentalFeatures. + * @member {google.api.PythonSettings.IExperimentalFeatures|null|undefined} experimentalFeatures + * @memberof google.api.PythonSettings + * @instance + */ + PythonSettings.prototype.experimentalFeatures = null; + + /** + * Creates a new PythonSettings instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings + * @static + * @param {google.api.IPythonSettings=} [properties] Properties to set + * @returns {google.api.PythonSettings} PythonSettings instance + */ + PythonSettings.create = function create(properties) { + return new PythonSettings(properties); + }; + + /** + * Encodes the specified PythonSettings message. Does not implicitly {@link google.api.PythonSettings.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings + * @static + * @param {google.api.IPythonSettings} message PythonSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PythonSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.experimentalFeatures != null && Object.hasOwnProperty.call(message, "experimentalFeatures")) + $root.google.api.PythonSettings.ExperimentalFeatures.encode(message.experimentalFeatures, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified PythonSettings message, length delimited. Does not implicitly {@link google.api.PythonSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings + * @static + * @param {google.api.IPythonSettings} message PythonSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PythonSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PythonSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings} PythonSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PythonSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + case 2: { + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PythonSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings} PythonSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PythonSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PythonSettings message. + * @function verify + * @memberof google.api.PythonSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PythonSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) { + var error = $root.google.api.PythonSettings.ExperimentalFeatures.verify(message.experimentalFeatures); + if (error) + return "experimentalFeatures." + error; + } + return null; + }; + + /** + * Creates a PythonSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings} PythonSettings + */ + PythonSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings) + return object; + var message = new $root.google.api.PythonSettings(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.PythonSettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + if (object.experimentalFeatures != null) { + if (typeof object.experimentalFeatures !== "object") + throw TypeError(".google.api.PythonSettings.experimentalFeatures: object expected"); + message.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.fromObject(object.experimentalFeatures); + } + return message; + }; + + /** + * Creates a plain object from a PythonSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings + * @static + * @param {google.api.PythonSettings} message PythonSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PythonSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.common = null; + object.experimentalFeatures = null; + } + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + if (message.experimentalFeatures != null && message.hasOwnProperty("experimentalFeatures")) + object.experimentalFeatures = $root.google.api.PythonSettings.ExperimentalFeatures.toObject(message.experimentalFeatures, options); + return object; + }; + + /** + * Converts this PythonSettings to JSON. + * @function toJSON + * @memberof google.api.PythonSettings + * @instance + * @returns {Object.} JSON object + */ + PythonSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for PythonSettings + * @function getTypeUrl + * @memberof google.api.PythonSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + PythonSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings"; + }; + + PythonSettings.ExperimentalFeatures = (function() { + + /** + * Properties of an ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @interface IExperimentalFeatures + * @property {boolean|null} [restAsyncIoEnabled] ExperimentalFeatures restAsyncIoEnabled + * @property {boolean|null} [protobufPythonicTypesEnabled] ExperimentalFeatures protobufPythonicTypesEnabled + * @property {boolean|null} [unversionedPackageDisabled] ExperimentalFeatures unversionedPackageDisabled + */ + + /** + * Constructs a new ExperimentalFeatures. + * @memberof google.api.PythonSettings + * @classdesc Represents an ExperimentalFeatures. + * @implements IExperimentalFeatures + * @constructor + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + */ + function ExperimentalFeatures(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExperimentalFeatures restAsyncIoEnabled. + * @member {boolean} restAsyncIoEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.restAsyncIoEnabled = false; + + /** + * ExperimentalFeatures protobufPythonicTypesEnabled. + * @member {boolean} protobufPythonicTypesEnabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.protobufPythonicTypesEnabled = false; + + /** + * ExperimentalFeatures unversionedPackageDisabled. + * @member {boolean} unversionedPackageDisabled + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + */ + ExperimentalFeatures.prototype.unversionedPackageDisabled = false; + + /** + * Creates a new ExperimentalFeatures instance using the specified properties. + * @function create + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures=} [properties] Properties to set + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures instance + */ + ExperimentalFeatures.create = function create(properties) { + return new ExperimentalFeatures(properties); + }; + + /** + * Encodes the specified ExperimentalFeatures message. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.restAsyncIoEnabled != null && Object.hasOwnProperty.call(message, "restAsyncIoEnabled")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.restAsyncIoEnabled); + if (message.protobufPythonicTypesEnabled != null && Object.hasOwnProperty.call(message, "protobufPythonicTypesEnabled")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.protobufPythonicTypesEnabled); + if (message.unversionedPackageDisabled != null && Object.hasOwnProperty.call(message, "unversionedPackageDisabled")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.unversionedPackageDisabled); + return writer; + }; + + /** + * Encodes the specified ExperimentalFeatures message, length delimited. Does not implicitly {@link google.api.PythonSettings.ExperimentalFeatures.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.IExperimentalFeatures} message ExperimentalFeatures message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExperimentalFeatures.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer. + * @function decode + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.restAsyncIoEnabled = reader.bool(); + break; + } + case 2: { + message.protobufPythonicTypesEnabled = reader.bool(); + break; + } + case 3: { + message.unversionedPackageDisabled = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExperimentalFeatures message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExperimentalFeatures.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExperimentalFeatures message. + * @function verify + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExperimentalFeatures.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + if (typeof message.restAsyncIoEnabled !== "boolean") + return "restAsyncIoEnabled: boolean expected"; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + if (typeof message.protobufPythonicTypesEnabled !== "boolean") + return "protobufPythonicTypesEnabled: boolean expected"; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + if (typeof message.unversionedPackageDisabled !== "boolean") + return "unversionedPackageDisabled: boolean expected"; + return null; + }; + + /** + * Creates an ExperimentalFeatures message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {Object.} object Plain object + * @returns {google.api.PythonSettings.ExperimentalFeatures} ExperimentalFeatures + */ + ExperimentalFeatures.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.PythonSettings.ExperimentalFeatures) + return object; + var message = new $root.google.api.PythonSettings.ExperimentalFeatures(); + if (object.restAsyncIoEnabled != null) + message.restAsyncIoEnabled = Boolean(object.restAsyncIoEnabled); + if (object.protobufPythonicTypesEnabled != null) + message.protobufPythonicTypesEnabled = Boolean(object.protobufPythonicTypesEnabled); + if (object.unversionedPackageDisabled != null) + message.unversionedPackageDisabled = Boolean(object.unversionedPackageDisabled); + return message; + }; + + /** + * Creates a plain object from an ExperimentalFeatures message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {google.api.PythonSettings.ExperimentalFeatures} message ExperimentalFeatures + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExperimentalFeatures.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.restAsyncIoEnabled = false; + object.protobufPythonicTypesEnabled = false; + object.unversionedPackageDisabled = false; + } + if (message.restAsyncIoEnabled != null && message.hasOwnProperty("restAsyncIoEnabled")) + object.restAsyncIoEnabled = message.restAsyncIoEnabled; + if (message.protobufPythonicTypesEnabled != null && message.hasOwnProperty("protobufPythonicTypesEnabled")) + object.protobufPythonicTypesEnabled = message.protobufPythonicTypesEnabled; + if (message.unversionedPackageDisabled != null && message.hasOwnProperty("unversionedPackageDisabled")) + object.unversionedPackageDisabled = message.unversionedPackageDisabled; + return object; + }; + + /** + * Converts this ExperimentalFeatures to JSON. + * @function toJSON + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @instance + * @returns {Object.} JSON object + */ + ExperimentalFeatures.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExperimentalFeatures + * @function getTypeUrl + * @memberof google.api.PythonSettings.ExperimentalFeatures + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExperimentalFeatures.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.PythonSettings.ExperimentalFeatures"; + }; + + return ExperimentalFeatures; + })(); + + return PythonSettings; + })(); + + api.NodeSettings = (function() { + + /** + * Properties of a NodeSettings. + * @memberof google.api + * @interface INodeSettings + * @property {google.api.ICommonLanguageSettings|null} [common] NodeSettings common + */ + + /** + * Constructs a new NodeSettings. + * @memberof google.api + * @classdesc Represents a NodeSettings. + * @implements INodeSettings + * @constructor + * @param {google.api.INodeSettings=} [properties] Properties to set + */ + function NodeSettings(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NodeSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.NodeSettings + * @instance + */ + NodeSettings.prototype.common = null; + + /** + * Creates a new NodeSettings instance using the specified properties. + * @function create + * @memberof google.api.NodeSettings + * @static + * @param {google.api.INodeSettings=} [properties] Properties to set + * @returns {google.api.NodeSettings} NodeSettings instance + */ + NodeSettings.create = function create(properties) { + return new NodeSettings(properties); + }; + + /** + * Encodes the specified NodeSettings message. Does not implicitly {@link google.api.NodeSettings.verify|verify} messages. + * @function encode + * @memberof google.api.NodeSettings + * @static + * @param {google.api.INodeSettings} message NodeSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NodeSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified NodeSettings message, length delimited. Does not implicitly {@link google.api.NodeSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.NodeSettings + * @static + * @param {google.api.INodeSettings} message NodeSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NodeSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a NodeSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.NodeSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.NodeSettings} NodeSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NodeSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.NodeSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a NodeSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.NodeSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.NodeSettings} NodeSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NodeSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a NodeSettings message. + * @function verify + * @memberof google.api.NodeSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NodeSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + return null; + }; + + /** + * Creates a NodeSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.NodeSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.NodeSettings} NodeSettings + */ + NodeSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.NodeSettings) + return object; + var message = new $root.google.api.NodeSettings(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.NodeSettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + return message; + }; + + /** + * Creates a plain object from a NodeSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.NodeSettings + * @static + * @param {google.api.NodeSettings} message NodeSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NodeSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.common = null; + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + return object; + }; + + /** + * Converts this NodeSettings to JSON. + * @function toJSON + * @memberof google.api.NodeSettings + * @instance + * @returns {Object.} JSON object + */ + NodeSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for NodeSettings + * @function getTypeUrl + * @memberof google.api.NodeSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + NodeSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.NodeSettings"; + }; + + return NodeSettings; + })(); + + api.DotnetSettings = (function() { + + /** + * Properties of a DotnetSettings. + * @memberof google.api + * @interface IDotnetSettings + * @property {google.api.ICommonLanguageSettings|null} [common] DotnetSettings common + * @property {Object.|null} [renamedServices] DotnetSettings renamedServices + * @property {Object.|null} [renamedResources] DotnetSettings renamedResources + * @property {Array.|null} [ignoredResources] DotnetSettings ignoredResources + * @property {Array.|null} [forcedNamespaceAliases] DotnetSettings forcedNamespaceAliases + * @property {Array.|null} [handwrittenSignatures] DotnetSettings handwrittenSignatures + */ + + /** + * Constructs a new DotnetSettings. + * @memberof google.api + * @classdesc Represents a DotnetSettings. + * @implements IDotnetSettings + * @constructor + * @param {google.api.IDotnetSettings=} [properties] Properties to set + */ + function DotnetSettings(properties) { + this.renamedServices = {}; + this.renamedResources = {}; + this.ignoredResources = []; + this.forcedNamespaceAliases = []; + this.handwrittenSignatures = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DotnetSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.DotnetSettings + * @instance + */ + DotnetSettings.prototype.common = null; + + /** + * DotnetSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.DotnetSettings + * @instance + */ + DotnetSettings.prototype.renamedServices = $util.emptyObject; + + /** + * DotnetSettings renamedResources. + * @member {Object.} renamedResources + * @memberof google.api.DotnetSettings + * @instance + */ + DotnetSettings.prototype.renamedResources = $util.emptyObject; + + /** + * DotnetSettings ignoredResources. + * @member {Array.} ignoredResources + * @memberof google.api.DotnetSettings + * @instance + */ + DotnetSettings.prototype.ignoredResources = $util.emptyArray; + + /** + * DotnetSettings forcedNamespaceAliases. + * @member {Array.} forcedNamespaceAliases + * @memberof google.api.DotnetSettings + * @instance + */ + DotnetSettings.prototype.forcedNamespaceAliases = $util.emptyArray; + + /** + * DotnetSettings handwrittenSignatures. + * @member {Array.} handwrittenSignatures + * @memberof google.api.DotnetSettings + * @instance + */ + DotnetSettings.prototype.handwrittenSignatures = $util.emptyArray; + + /** + * Creates a new DotnetSettings instance using the specified properties. + * @function create + * @memberof google.api.DotnetSettings + * @static + * @param {google.api.IDotnetSettings=} [properties] Properties to set + * @returns {google.api.DotnetSettings} DotnetSettings instance + */ + DotnetSettings.create = function create(properties) { + return new DotnetSettings(properties); + }; + + /** + * Encodes the specified DotnetSettings message. Does not implicitly {@link google.api.DotnetSettings.verify|verify} messages. + * @function encode + * @memberof google.api.DotnetSettings + * @static + * @param {google.api.IDotnetSettings} message DotnetSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DotnetSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); + if (message.renamedResources != null && Object.hasOwnProperty.call(message, "renamedResources")) + for (var keys = Object.keys(message.renamedResources), i = 0; i < keys.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedResources[keys[i]]).ldelim(); + if (message.ignoredResources != null && message.ignoredResources.length) + for (var i = 0; i < message.ignoredResources.length; ++i) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.ignoredResources[i]); + if (message.forcedNamespaceAliases != null && message.forcedNamespaceAliases.length) + for (var i = 0; i < message.forcedNamespaceAliases.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.forcedNamespaceAliases[i]); + if (message.handwrittenSignatures != null && message.handwrittenSignatures.length) + for (var i = 0; i < message.handwrittenSignatures.length; ++i) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.handwrittenSignatures[i]); + return writer; + }; + + /** + * Encodes the specified DotnetSettings message, length delimited. Does not implicitly {@link google.api.DotnetSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.DotnetSettings + * @static + * @param {google.api.IDotnetSettings} message DotnetSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DotnetSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DotnetSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.DotnetSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.DotnetSettings} DotnetSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DotnetSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.DotnetSettings(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } + case 3: { + if (message.renamedResources === $util.emptyObject) + message.renamedResources = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedResources[key] = value; + break; + } + case 4: { + if (!(message.ignoredResources && message.ignoredResources.length)) + message.ignoredResources = []; + message.ignoredResources.push(reader.string()); + break; + } + case 5: { + if (!(message.forcedNamespaceAliases && message.forcedNamespaceAliases.length)) + message.forcedNamespaceAliases = []; + message.forcedNamespaceAliases.push(reader.string()); + break; + } + case 6: { + if (!(message.handwrittenSignatures && message.handwrittenSignatures.length)) + message.handwrittenSignatures = []; + message.handwrittenSignatures.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DotnetSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.DotnetSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.DotnetSettings} DotnetSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DotnetSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DotnetSettings message. + * @function verify + * @memberof google.api.DotnetSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DotnetSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } + if (message.renamedResources != null && message.hasOwnProperty("renamedResources")) { + if (!$util.isObject(message.renamedResources)) + return "renamedResources: object expected"; + var key = Object.keys(message.renamedResources); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedResources[key[i]])) + return "renamedResources: string{k:string} expected"; + } + if (message.ignoredResources != null && message.hasOwnProperty("ignoredResources")) { + if (!Array.isArray(message.ignoredResources)) + return "ignoredResources: array expected"; + for (var i = 0; i < message.ignoredResources.length; ++i) + if (!$util.isString(message.ignoredResources[i])) + return "ignoredResources: string[] expected"; + } + if (message.forcedNamespaceAliases != null && message.hasOwnProperty("forcedNamespaceAliases")) { + if (!Array.isArray(message.forcedNamespaceAliases)) + return "forcedNamespaceAliases: array expected"; + for (var i = 0; i < message.forcedNamespaceAliases.length; ++i) + if (!$util.isString(message.forcedNamespaceAliases[i])) + return "forcedNamespaceAliases: string[] expected"; + } + if (message.handwrittenSignatures != null && message.hasOwnProperty("handwrittenSignatures")) { + if (!Array.isArray(message.handwrittenSignatures)) + return "handwrittenSignatures: array expected"; + for (var i = 0; i < message.handwrittenSignatures.length; ++i) + if (!$util.isString(message.handwrittenSignatures[i])) + return "handwrittenSignatures: string[] expected"; + } + return null; + }; + + /** + * Creates a DotnetSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.DotnetSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.DotnetSettings} DotnetSettings + */ + DotnetSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.DotnetSettings) + return object; + var message = new $root.google.api.DotnetSettings(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.DotnetSettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.DotnetSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } + if (object.renamedResources) { + if (typeof object.renamedResources !== "object") + throw TypeError(".google.api.DotnetSettings.renamedResources: object expected"); + message.renamedResources = {}; + for (var keys = Object.keys(object.renamedResources), i = 0; i < keys.length; ++i) + message.renamedResources[keys[i]] = String(object.renamedResources[keys[i]]); + } + if (object.ignoredResources) { + if (!Array.isArray(object.ignoredResources)) + throw TypeError(".google.api.DotnetSettings.ignoredResources: array expected"); + message.ignoredResources = []; + for (var i = 0; i < object.ignoredResources.length; ++i) + message.ignoredResources[i] = String(object.ignoredResources[i]); + } + if (object.forcedNamespaceAliases) { + if (!Array.isArray(object.forcedNamespaceAliases)) + throw TypeError(".google.api.DotnetSettings.forcedNamespaceAliases: array expected"); + message.forcedNamespaceAliases = []; + for (var i = 0; i < object.forcedNamespaceAliases.length; ++i) + message.forcedNamespaceAliases[i] = String(object.forcedNamespaceAliases[i]); + } + if (object.handwrittenSignatures) { + if (!Array.isArray(object.handwrittenSignatures)) + throw TypeError(".google.api.DotnetSettings.handwrittenSignatures: array expected"); + message.handwrittenSignatures = []; + for (var i = 0; i < object.handwrittenSignatures.length; ++i) + message.handwrittenSignatures[i] = String(object.handwrittenSignatures[i]); + } + return message; + }; + + /** + * Creates a plain object from a DotnetSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.DotnetSettings + * @static + * @param {google.api.DotnetSettings} message DotnetSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DotnetSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.ignoredResources = []; + object.forcedNamespaceAliases = []; + object.handwrittenSignatures = []; + } + if (options.objects || options.defaults) { + object.renamedServices = {}; + object.renamedResources = {}; + } + if (options.defaults) + object.common = null; + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } + if (message.renamedResources && (keys2 = Object.keys(message.renamedResources)).length) { + object.renamedResources = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedResources[keys2[j]] = message.renamedResources[keys2[j]]; + } + if (message.ignoredResources && message.ignoredResources.length) { + object.ignoredResources = []; + for (var j = 0; j < message.ignoredResources.length; ++j) + object.ignoredResources[j] = message.ignoredResources[j]; + } + if (message.forcedNamespaceAliases && message.forcedNamespaceAliases.length) { + object.forcedNamespaceAliases = []; + for (var j = 0; j < message.forcedNamespaceAliases.length; ++j) + object.forcedNamespaceAliases[j] = message.forcedNamespaceAliases[j]; + } + if (message.handwrittenSignatures && message.handwrittenSignatures.length) { + object.handwrittenSignatures = []; + for (var j = 0; j < message.handwrittenSignatures.length; ++j) + object.handwrittenSignatures[j] = message.handwrittenSignatures[j]; + } + return object; + }; + + /** + * Converts this DotnetSettings to JSON. + * @function toJSON + * @memberof google.api.DotnetSettings + * @instance + * @returns {Object.} JSON object + */ + DotnetSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DotnetSettings + * @function getTypeUrl + * @memberof google.api.DotnetSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DotnetSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.DotnetSettings"; + }; + + return DotnetSettings; + })(); + + api.RubySettings = (function() { + + /** + * Properties of a RubySettings. + * @memberof google.api + * @interface IRubySettings + * @property {google.api.ICommonLanguageSettings|null} [common] RubySettings common + */ + + /** + * Constructs a new RubySettings. + * @memberof google.api + * @classdesc Represents a RubySettings. + * @implements IRubySettings + * @constructor + * @param {google.api.IRubySettings=} [properties] Properties to set + */ + function RubySettings(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RubySettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.RubySettings + * @instance + */ + RubySettings.prototype.common = null; + + /** + * Creates a new RubySettings instance using the specified properties. + * @function create + * @memberof google.api.RubySettings + * @static + * @param {google.api.IRubySettings=} [properties] Properties to set + * @returns {google.api.RubySettings} RubySettings instance + */ + RubySettings.create = function create(properties) { + return new RubySettings(properties); + }; + + /** + * Encodes the specified RubySettings message. Does not implicitly {@link google.api.RubySettings.verify|verify} messages. + * @function encode + * @memberof google.api.RubySettings + * @static + * @param {google.api.IRubySettings} message RubySettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RubySettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RubySettings message, length delimited. Does not implicitly {@link google.api.RubySettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.RubySettings + * @static + * @param {google.api.IRubySettings} message RubySettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RubySettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RubySettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.RubySettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.RubySettings} RubySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RubySettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.RubySettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RubySettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.RubySettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.RubySettings} RubySettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RubySettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RubySettings message. + * @function verify + * @memberof google.api.RubySettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RubySettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + return null; + }; + + /** + * Creates a RubySettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.RubySettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.RubySettings} RubySettings + */ + RubySettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.RubySettings) + return object; + var message = new $root.google.api.RubySettings(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.RubySettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + return message; + }; + + /** + * Creates a plain object from a RubySettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.RubySettings + * @static + * @param {google.api.RubySettings} message RubySettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RubySettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.common = null; + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + return object; + }; + + /** + * Converts this RubySettings to JSON. + * @function toJSON + * @memberof google.api.RubySettings + * @instance + * @returns {Object.} JSON object + */ + RubySettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RubySettings + * @function getTypeUrl + * @memberof google.api.RubySettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RubySettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.RubySettings"; + }; + + return RubySettings; + })(); + + api.GoSettings = (function() { + + /** + * Properties of a GoSettings. + * @memberof google.api + * @interface IGoSettings + * @property {google.api.ICommonLanguageSettings|null} [common] GoSettings common + * @property {Object.|null} [renamedServices] GoSettings renamedServices + */ + + /** + * Constructs a new GoSettings. + * @memberof google.api + * @classdesc Represents a GoSettings. + * @implements IGoSettings + * @constructor + * @param {google.api.IGoSettings=} [properties] Properties to set + */ + function GoSettings(properties) { + this.renamedServices = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GoSettings common. + * @member {google.api.ICommonLanguageSettings|null|undefined} common + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.common = null; + + /** + * GoSettings renamedServices. + * @member {Object.} renamedServices + * @memberof google.api.GoSettings + * @instance + */ + GoSettings.prototype.renamedServices = $util.emptyObject; + + /** + * Creates a new GoSettings instance using the specified properties. + * @function create + * @memberof google.api.GoSettings + * @static + * @param {google.api.IGoSettings=} [properties] Properties to set + * @returns {google.api.GoSettings} GoSettings instance + */ + GoSettings.create = function create(properties) { + return new GoSettings(properties); + }; + + /** + * Encodes the specified GoSettings message. Does not implicitly {@link google.api.GoSettings.verify|verify} messages. + * @function encode + * @memberof google.api.GoSettings + * @static + * @param {google.api.IGoSettings} message GoSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GoSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.common != null && Object.hasOwnProperty.call(message, "common")) + $root.google.api.CommonLanguageSettings.encode(message.common, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.renamedServices != null && Object.hasOwnProperty.call(message, "renamedServices")) + for (var keys = Object.keys(message.renamedServices), i = 0; i < keys.length; ++i) + writer.uint32(/* id 2, wireType 2 =*/18).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]).uint32(/* id 2, wireType 2 =*/18).string(message.renamedServices[keys[i]]).ldelim(); + return writer; + }; + + /** + * Encodes the specified GoSettings message, length delimited. Does not implicitly {@link google.api.GoSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.GoSettings + * @static + * @param {google.api.IGoSettings} message GoSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GoSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GoSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.GoSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.GoSettings} GoSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GoSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.GoSettings(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.common = $root.google.api.CommonLanguageSettings.decode(reader, reader.uint32()); + break; + } + case 2: { + if (message.renamedServices === $util.emptyObject) + message.renamedServices = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = ""; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = reader.string(); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.renamedServices[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GoSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.GoSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.GoSettings} GoSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GoSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GoSettings message. + * @function verify + * @memberof google.api.GoSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GoSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.common != null && message.hasOwnProperty("common")) { + var error = $root.google.api.CommonLanguageSettings.verify(message.common); + if (error) + return "common." + error; + } + if (message.renamedServices != null && message.hasOwnProperty("renamedServices")) { + if (!$util.isObject(message.renamedServices)) + return "renamedServices: object expected"; + var key = Object.keys(message.renamedServices); + for (var i = 0; i < key.length; ++i) + if (!$util.isString(message.renamedServices[key[i]])) + return "renamedServices: string{k:string} expected"; + } + return null; + }; + + /** + * Creates a GoSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.GoSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.GoSettings} GoSettings + */ + GoSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.GoSettings) + return object; + var message = new $root.google.api.GoSettings(); + if (object.common != null) { + if (typeof object.common !== "object") + throw TypeError(".google.api.GoSettings.common: object expected"); + message.common = $root.google.api.CommonLanguageSettings.fromObject(object.common); + } + if (object.renamedServices) { + if (typeof object.renamedServices !== "object") + throw TypeError(".google.api.GoSettings.renamedServices: object expected"); + message.renamedServices = {}; + for (var keys = Object.keys(object.renamedServices), i = 0; i < keys.length; ++i) + message.renamedServices[keys[i]] = String(object.renamedServices[keys[i]]); + } + return message; + }; + + /** + * Creates a plain object from a GoSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.GoSettings + * @static + * @param {google.api.GoSettings} message GoSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GoSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.renamedServices = {}; + if (options.defaults) + object.common = null; + if (message.common != null && message.hasOwnProperty("common")) + object.common = $root.google.api.CommonLanguageSettings.toObject(message.common, options); + var keys2; + if (message.renamedServices && (keys2 = Object.keys(message.renamedServices)).length) { + object.renamedServices = {}; + for (var j = 0; j < keys2.length; ++j) + object.renamedServices[keys2[j]] = message.renamedServices[keys2[j]]; + } + return object; + }; + + /** + * Converts this GoSettings to JSON. + * @function toJSON + * @memberof google.api.GoSettings + * @instance + * @returns {Object.} JSON object + */ + GoSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GoSettings + * @function getTypeUrl + * @memberof google.api.GoSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GoSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.GoSettings"; + }; + + return GoSettings; + })(); + + api.MethodSettings = (function() { + + /** + * Properties of a MethodSettings. + * @memberof google.api + * @interface IMethodSettings + * @property {string|null} [selector] MethodSettings selector + * @property {google.api.MethodSettings.ILongRunning|null} [longRunning] MethodSettings longRunning + * @property {Array.|null} [autoPopulatedFields] MethodSettings autoPopulatedFields + */ + + /** + * Constructs a new MethodSettings. + * @memberof google.api + * @classdesc Represents a MethodSettings. + * @implements IMethodSettings + * @constructor + * @param {google.api.IMethodSettings=} [properties] Properties to set + */ + function MethodSettings(properties) { + this.autoPopulatedFields = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodSettings selector. + * @member {string} selector + * @memberof google.api.MethodSettings + * @instance + */ + MethodSettings.prototype.selector = ""; + + /** + * MethodSettings longRunning. + * @member {google.api.MethodSettings.ILongRunning|null|undefined} longRunning + * @memberof google.api.MethodSettings + * @instance + */ + MethodSettings.prototype.longRunning = null; + + /** + * MethodSettings autoPopulatedFields. + * @member {Array.} autoPopulatedFields + * @memberof google.api.MethodSettings + * @instance + */ + MethodSettings.prototype.autoPopulatedFields = $util.emptyArray; + + /** + * Creates a new MethodSettings instance using the specified properties. + * @function create + * @memberof google.api.MethodSettings + * @static + * @param {google.api.IMethodSettings=} [properties] Properties to set + * @returns {google.api.MethodSettings} MethodSettings instance + */ + MethodSettings.create = function create(properties) { + return new MethodSettings(properties); + }; + + /** + * Encodes the specified MethodSettings message. Does not implicitly {@link google.api.MethodSettings.verify|verify} messages. + * @function encode + * @memberof google.api.MethodSettings + * @static + * @param {google.api.IMethodSettings} message MethodSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodSettings.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.selector != null && Object.hasOwnProperty.call(message, "selector")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.selector); + if (message.longRunning != null && Object.hasOwnProperty.call(message, "longRunning")) + $root.google.api.MethodSettings.LongRunning.encode(message.longRunning, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.autoPopulatedFields != null && message.autoPopulatedFields.length) + for (var i = 0; i < message.autoPopulatedFields.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.autoPopulatedFields[i]); + return writer; + }; + + /** + * Encodes the specified MethodSettings message, length delimited. Does not implicitly {@link google.api.MethodSettings.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.MethodSettings + * @static + * @param {google.api.IMethodSettings} message MethodSettings message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodSettings.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MethodSettings message from the specified reader or buffer. + * @function decode + * @memberof google.api.MethodSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.MethodSettings} MethodSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodSettings.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.MethodSettings(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.selector = reader.string(); + break; + } + case 2: { + message.longRunning = $root.google.api.MethodSettings.LongRunning.decode(reader, reader.uint32()); + break; + } + case 3: { + if (!(message.autoPopulatedFields && message.autoPopulatedFields.length)) + message.autoPopulatedFields = []; + message.autoPopulatedFields.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MethodSettings message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.MethodSettings + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.MethodSettings} MethodSettings + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodSettings.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MethodSettings message. + * @function verify + * @memberof google.api.MethodSettings + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodSettings.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.selector != null && message.hasOwnProperty("selector")) + if (!$util.isString(message.selector)) + return "selector: string expected"; + if (message.longRunning != null && message.hasOwnProperty("longRunning")) { + var error = $root.google.api.MethodSettings.LongRunning.verify(message.longRunning); + if (error) + return "longRunning." + error; + } + if (message.autoPopulatedFields != null && message.hasOwnProperty("autoPopulatedFields")) { + if (!Array.isArray(message.autoPopulatedFields)) + return "autoPopulatedFields: array expected"; + for (var i = 0; i < message.autoPopulatedFields.length; ++i) + if (!$util.isString(message.autoPopulatedFields[i])) + return "autoPopulatedFields: string[] expected"; + } + return null; + }; + + /** + * Creates a MethodSettings message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.MethodSettings + * @static + * @param {Object.} object Plain object + * @returns {google.api.MethodSettings} MethodSettings + */ + MethodSettings.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.MethodSettings) + return object; + var message = new $root.google.api.MethodSettings(); + if (object.selector != null) + message.selector = String(object.selector); + if (object.longRunning != null) { + if (typeof object.longRunning !== "object") + throw TypeError(".google.api.MethodSettings.longRunning: object expected"); + message.longRunning = $root.google.api.MethodSettings.LongRunning.fromObject(object.longRunning); + } + if (object.autoPopulatedFields) { + if (!Array.isArray(object.autoPopulatedFields)) + throw TypeError(".google.api.MethodSettings.autoPopulatedFields: array expected"); + message.autoPopulatedFields = []; + for (var i = 0; i < object.autoPopulatedFields.length; ++i) + message.autoPopulatedFields[i] = String(object.autoPopulatedFields[i]); + } + return message; + }; + + /** + * Creates a plain object from a MethodSettings message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.MethodSettings + * @static + * @param {google.api.MethodSettings} message MethodSettings + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodSettings.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.autoPopulatedFields = []; + if (options.defaults) { + object.selector = ""; + object.longRunning = null; + } + if (message.selector != null && message.hasOwnProperty("selector")) + object.selector = message.selector; + if (message.longRunning != null && message.hasOwnProperty("longRunning")) + object.longRunning = $root.google.api.MethodSettings.LongRunning.toObject(message.longRunning, options); + if (message.autoPopulatedFields && message.autoPopulatedFields.length) { + object.autoPopulatedFields = []; + for (var j = 0; j < message.autoPopulatedFields.length; ++j) + object.autoPopulatedFields[j] = message.autoPopulatedFields[j]; + } + return object; + }; + + /** + * Converts this MethodSettings to JSON. + * @function toJSON + * @memberof google.api.MethodSettings + * @instance + * @returns {Object.} JSON object + */ + MethodSettings.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MethodSettings + * @function getTypeUrl + * @memberof google.api.MethodSettings + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MethodSettings.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.MethodSettings"; + }; + + MethodSettings.LongRunning = (function() { + + /** + * Properties of a LongRunning. + * @memberof google.api.MethodSettings + * @interface ILongRunning + * @property {google.protobuf.IDuration|null} [initialPollDelay] LongRunning initialPollDelay + * @property {number|null} [pollDelayMultiplier] LongRunning pollDelayMultiplier + * @property {google.protobuf.IDuration|null} [maxPollDelay] LongRunning maxPollDelay + * @property {google.protobuf.IDuration|null} [totalPollTimeout] LongRunning totalPollTimeout + */ + + /** + * Constructs a new LongRunning. + * @memberof google.api.MethodSettings + * @classdesc Represents a LongRunning. + * @implements ILongRunning + * @constructor + * @param {google.api.MethodSettings.ILongRunning=} [properties] Properties to set + */ + function LongRunning(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LongRunning initialPollDelay. + * @member {google.protobuf.IDuration|null|undefined} initialPollDelay + * @memberof google.api.MethodSettings.LongRunning + * @instance + */ + LongRunning.prototype.initialPollDelay = null; + + /** + * LongRunning pollDelayMultiplier. + * @member {number} pollDelayMultiplier + * @memberof google.api.MethodSettings.LongRunning + * @instance + */ + LongRunning.prototype.pollDelayMultiplier = 0; + + /** + * LongRunning maxPollDelay. + * @member {google.protobuf.IDuration|null|undefined} maxPollDelay + * @memberof google.api.MethodSettings.LongRunning + * @instance + */ + LongRunning.prototype.maxPollDelay = null; + + /** + * LongRunning totalPollTimeout. + * @member {google.protobuf.IDuration|null|undefined} totalPollTimeout + * @memberof google.api.MethodSettings.LongRunning + * @instance + */ + LongRunning.prototype.totalPollTimeout = null; + + /** + * Creates a new LongRunning instance using the specified properties. + * @function create + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {google.api.MethodSettings.ILongRunning=} [properties] Properties to set + * @returns {google.api.MethodSettings.LongRunning} LongRunning instance + */ + LongRunning.create = function create(properties) { + return new LongRunning(properties); + }; + + /** + * Encodes the specified LongRunning message. Does not implicitly {@link google.api.MethodSettings.LongRunning.verify|verify} messages. + * @function encode + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {google.api.MethodSettings.ILongRunning} message LongRunning message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LongRunning.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.initialPollDelay != null && Object.hasOwnProperty.call(message, "initialPollDelay")) + $root.google.protobuf.Duration.encode(message.initialPollDelay, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.pollDelayMultiplier != null && Object.hasOwnProperty.call(message, "pollDelayMultiplier")) + writer.uint32(/* id 2, wireType 5 =*/21).float(message.pollDelayMultiplier); + if (message.maxPollDelay != null && Object.hasOwnProperty.call(message, "maxPollDelay")) + $root.google.protobuf.Duration.encode(message.maxPollDelay, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.totalPollTimeout != null && Object.hasOwnProperty.call(message, "totalPollTimeout")) + $root.google.protobuf.Duration.encode(message.totalPollTimeout, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified LongRunning message, length delimited. Does not implicitly {@link google.api.MethodSettings.LongRunning.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {google.api.MethodSettings.ILongRunning} message LongRunning message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LongRunning.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LongRunning message from the specified reader or buffer. + * @function decode + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.MethodSettings.LongRunning} LongRunning + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LongRunning.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.MethodSettings.LongRunning(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.initialPollDelay = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 2: { + message.pollDelayMultiplier = reader.float(); + break; + } + case 3: { + message.maxPollDelay = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + case 4: { + message.totalPollTimeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LongRunning message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.MethodSettings.LongRunning} LongRunning + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LongRunning.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LongRunning message. + * @function verify + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LongRunning.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.initialPollDelay != null && message.hasOwnProperty("initialPollDelay")) { + var error = $root.google.protobuf.Duration.verify(message.initialPollDelay); + if (error) + return "initialPollDelay." + error; + } + if (message.pollDelayMultiplier != null && message.hasOwnProperty("pollDelayMultiplier")) + if (typeof message.pollDelayMultiplier !== "number") + return "pollDelayMultiplier: number expected"; + if (message.maxPollDelay != null && message.hasOwnProperty("maxPollDelay")) { + var error = $root.google.protobuf.Duration.verify(message.maxPollDelay); + if (error) + return "maxPollDelay." + error; + } + if (message.totalPollTimeout != null && message.hasOwnProperty("totalPollTimeout")) { + var error = $root.google.protobuf.Duration.verify(message.totalPollTimeout); + if (error) + return "totalPollTimeout." + error; + } + return null; + }; + + /** + * Creates a LongRunning message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {Object.} object Plain object + * @returns {google.api.MethodSettings.LongRunning} LongRunning + */ + LongRunning.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.MethodSettings.LongRunning) + return object; + var message = new $root.google.api.MethodSettings.LongRunning(); + if (object.initialPollDelay != null) { + if (typeof object.initialPollDelay !== "object") + throw TypeError(".google.api.MethodSettings.LongRunning.initialPollDelay: object expected"); + message.initialPollDelay = $root.google.protobuf.Duration.fromObject(object.initialPollDelay); + } + if (object.pollDelayMultiplier != null) + message.pollDelayMultiplier = Number(object.pollDelayMultiplier); + if (object.maxPollDelay != null) { + if (typeof object.maxPollDelay !== "object") + throw TypeError(".google.api.MethodSettings.LongRunning.maxPollDelay: object expected"); + message.maxPollDelay = $root.google.protobuf.Duration.fromObject(object.maxPollDelay); + } + if (object.totalPollTimeout != null) { + if (typeof object.totalPollTimeout !== "object") + throw TypeError(".google.api.MethodSettings.LongRunning.totalPollTimeout: object expected"); + message.totalPollTimeout = $root.google.protobuf.Duration.fromObject(object.totalPollTimeout); + } + return message; + }; + + /** + * Creates a plain object from a LongRunning message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {google.api.MethodSettings.LongRunning} message LongRunning + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LongRunning.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.initialPollDelay = null; + object.pollDelayMultiplier = 0; + object.maxPollDelay = null; + object.totalPollTimeout = null; + } + if (message.initialPollDelay != null && message.hasOwnProperty("initialPollDelay")) + object.initialPollDelay = $root.google.protobuf.Duration.toObject(message.initialPollDelay, options); + if (message.pollDelayMultiplier != null && message.hasOwnProperty("pollDelayMultiplier")) + object.pollDelayMultiplier = options.json && !isFinite(message.pollDelayMultiplier) ? String(message.pollDelayMultiplier) : message.pollDelayMultiplier; + if (message.maxPollDelay != null && message.hasOwnProperty("maxPollDelay")) + object.maxPollDelay = $root.google.protobuf.Duration.toObject(message.maxPollDelay, options); + if (message.totalPollTimeout != null && message.hasOwnProperty("totalPollTimeout")) + object.totalPollTimeout = $root.google.protobuf.Duration.toObject(message.totalPollTimeout, options); + return object; + }; + + /** + * Converts this LongRunning to JSON. + * @function toJSON + * @memberof google.api.MethodSettings.LongRunning + * @instance + * @returns {Object.} JSON object + */ + LongRunning.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LongRunning + * @function getTypeUrl + * @memberof google.api.MethodSettings.LongRunning + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LongRunning.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.MethodSettings.LongRunning"; + }; + + return LongRunning; + })(); + + return MethodSettings; + })(); + + /** + * ClientLibraryOrganization enum. + * @name google.api.ClientLibraryOrganization + * @enum {number} + * @property {number} CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED=0 CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED value + * @property {number} CLOUD=1 CLOUD value + * @property {number} ADS=2 ADS value + * @property {number} PHOTOS=3 PHOTOS value + * @property {number} STREET_VIEW=4 STREET_VIEW value + * @property {number} SHOPPING=5 SHOPPING value + * @property {number} GEO=6 GEO value + * @property {number} GENERATIVE_AI=7 GENERATIVE_AI value + */ + api.ClientLibraryOrganization = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED"] = 0; + values[valuesById[1] = "CLOUD"] = 1; + values[valuesById[2] = "ADS"] = 2; + values[valuesById[3] = "PHOTOS"] = 3; + values[valuesById[4] = "STREET_VIEW"] = 4; + values[valuesById[5] = "SHOPPING"] = 5; + values[valuesById[6] = "GEO"] = 6; + values[valuesById[7] = "GENERATIVE_AI"] = 7; + return values; + })(); + + /** + * ClientLibraryDestination enum. + * @name google.api.ClientLibraryDestination + * @enum {number} + * @property {number} CLIENT_LIBRARY_DESTINATION_UNSPECIFIED=0 CLIENT_LIBRARY_DESTINATION_UNSPECIFIED value + * @property {number} GITHUB=10 GITHUB value + * @property {number} PACKAGE_MANAGER=20 PACKAGE_MANAGER value + */ + api.ClientLibraryDestination = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "CLIENT_LIBRARY_DESTINATION_UNSPECIFIED"] = 0; + values[valuesById[10] = "GITHUB"] = 10; + values[valuesById[20] = "PACKAGE_MANAGER"] = 20; + return values; + })(); + + api.SelectiveGapicGeneration = (function() { + + /** + * Properties of a SelectiveGapicGeneration. + * @memberof google.api + * @interface ISelectiveGapicGeneration + * @property {Array.|null} [methods] SelectiveGapicGeneration methods + * @property {boolean|null} [generateOmittedAsInternal] SelectiveGapicGeneration generateOmittedAsInternal + */ + + /** + * Constructs a new SelectiveGapicGeneration. + * @memberof google.api + * @classdesc Represents a SelectiveGapicGeneration. + * @implements ISelectiveGapicGeneration + * @constructor + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + */ + function SelectiveGapicGeneration(properties) { + this.methods = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SelectiveGapicGeneration methods. + * @member {Array.} methods + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.methods = $util.emptyArray; + + /** + * SelectiveGapicGeneration generateOmittedAsInternal. + * @member {boolean} generateOmittedAsInternal + * @memberof google.api.SelectiveGapicGeneration + * @instance + */ + SelectiveGapicGeneration.prototype.generateOmittedAsInternal = false; + + /** + * Creates a new SelectiveGapicGeneration instance using the specified properties. + * @function create + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration=} [properties] Properties to set + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration instance + */ + SelectiveGapicGeneration.create = function create(properties) { + return new SelectiveGapicGeneration(properties); + }; + + /** + * Encodes the specified SelectiveGapicGeneration message. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.methods != null && message.methods.length) + for (var i = 0; i < message.methods.length; ++i) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.methods[i]); + if (message.generateOmittedAsInternal != null && Object.hasOwnProperty.call(message, "generateOmittedAsInternal")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.generateOmittedAsInternal); + return writer; + }; + + /** + * Encodes the specified SelectiveGapicGeneration message, length delimited. Does not implicitly {@link google.api.SelectiveGapicGeneration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.ISelectiveGapicGeneration} message SelectiveGapicGeneration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SelectiveGapicGeneration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer. + * @function decode + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.SelectiveGapicGeneration(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.methods && message.methods.length)) + message.methods = []; + message.methods.push(reader.string()); + break; + } + case 2: { + message.generateOmittedAsInternal = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SelectiveGapicGeneration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SelectiveGapicGeneration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SelectiveGapicGeneration message. + * @function verify + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SelectiveGapicGeneration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.methods != null && message.hasOwnProperty("methods")) { + if (!Array.isArray(message.methods)) + return "methods: array expected"; + for (var i = 0; i < message.methods.length; ++i) + if (!$util.isString(message.methods[i])) + return "methods: string[] expected"; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + if (typeof message.generateOmittedAsInternal !== "boolean") + return "generateOmittedAsInternal: boolean expected"; + return null; + }; + + /** + * Creates a SelectiveGapicGeneration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {Object.} object Plain object + * @returns {google.api.SelectiveGapicGeneration} SelectiveGapicGeneration + */ + SelectiveGapicGeneration.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.SelectiveGapicGeneration) + return object; + var message = new $root.google.api.SelectiveGapicGeneration(); + if (object.methods) { + if (!Array.isArray(object.methods)) + throw TypeError(".google.api.SelectiveGapicGeneration.methods: array expected"); + message.methods = []; + for (var i = 0; i < object.methods.length; ++i) + message.methods[i] = String(object.methods[i]); + } + if (object.generateOmittedAsInternal != null) + message.generateOmittedAsInternal = Boolean(object.generateOmittedAsInternal); + return message; + }; + + /** + * Creates a plain object from a SelectiveGapicGeneration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {google.api.SelectiveGapicGeneration} message SelectiveGapicGeneration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SelectiveGapicGeneration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.methods = []; + if (options.defaults) + object.generateOmittedAsInternal = false; + if (message.methods && message.methods.length) { + object.methods = []; + for (var j = 0; j < message.methods.length; ++j) + object.methods[j] = message.methods[j]; + } + if (message.generateOmittedAsInternal != null && message.hasOwnProperty("generateOmittedAsInternal")) + object.generateOmittedAsInternal = message.generateOmittedAsInternal; + return object; + }; + + /** + * Converts this SelectiveGapicGeneration to JSON. + * @function toJSON + * @memberof google.api.SelectiveGapicGeneration + * @instance + * @returns {Object.} JSON object + */ + SelectiveGapicGeneration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SelectiveGapicGeneration + * @function getTypeUrl + * @memberof google.api.SelectiveGapicGeneration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SelectiveGapicGeneration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.SelectiveGapicGeneration"; + }; + + return SelectiveGapicGeneration; + })(); + + /** + * LaunchStage enum. + * @name google.api.LaunchStage + * @enum {number} + * @property {number} LAUNCH_STAGE_UNSPECIFIED=0 LAUNCH_STAGE_UNSPECIFIED value + * @property {number} UNIMPLEMENTED=6 UNIMPLEMENTED value + * @property {number} PRELAUNCH=7 PRELAUNCH value + * @property {number} EARLY_ACCESS=1 EARLY_ACCESS value + * @property {number} ALPHA=2 ALPHA value + * @property {number} BETA=3 BETA value + * @property {number} GA=4 GA value + * @property {number} DEPRECATED=5 DEPRECATED value + */ + api.LaunchStage = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LAUNCH_STAGE_UNSPECIFIED"] = 0; + values[valuesById[6] = "UNIMPLEMENTED"] = 6; + values[valuesById[7] = "PRELAUNCH"] = 7; + values[valuesById[1] = "EARLY_ACCESS"] = 1; + values[valuesById[2] = "ALPHA"] = 2; + values[valuesById[3] = "BETA"] = 3; + values[valuesById[4] = "GA"] = 4; + values[valuesById[5] = "DEPRECATED"] = 5; + return values; + })(); + + /** + * FieldBehavior enum. + * @name google.api.FieldBehavior + * @enum {number} + * @property {number} FIELD_BEHAVIOR_UNSPECIFIED=0 FIELD_BEHAVIOR_UNSPECIFIED value + * @property {number} OPTIONAL=1 OPTIONAL value + * @property {number} REQUIRED=2 REQUIRED value + * @property {number} OUTPUT_ONLY=3 OUTPUT_ONLY value + * @property {number} INPUT_ONLY=4 INPUT_ONLY value + * @property {number} IMMUTABLE=5 IMMUTABLE value + * @property {number} UNORDERED_LIST=6 UNORDERED_LIST value + * @property {number} NON_EMPTY_DEFAULT=7 NON_EMPTY_DEFAULT value + * @property {number} IDENTIFIER=8 IDENTIFIER value + */ + api.FieldBehavior = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_BEHAVIOR_UNSPECIFIED"] = 0; + values[valuesById[1] = "OPTIONAL"] = 1; + values[valuesById[2] = "REQUIRED"] = 2; + values[valuesById[3] = "OUTPUT_ONLY"] = 3; + values[valuesById[4] = "INPUT_ONLY"] = 4; + values[valuesById[5] = "IMMUTABLE"] = 5; + values[valuesById[6] = "UNORDERED_LIST"] = 6; + values[valuesById[7] = "NON_EMPTY_DEFAULT"] = 7; + values[valuesById[8] = "IDENTIFIER"] = 8; + return values; + })(); + + api.RoutingRule = (function() { + + /** + * Properties of a RoutingRule. + * @memberof google.api + * @interface IRoutingRule + * @property {Array.|null} [routingParameters] RoutingRule routingParameters + */ + + /** + * Constructs a new RoutingRule. + * @memberof google.api + * @classdesc Represents a RoutingRule. + * @implements IRoutingRule + * @constructor + * @param {google.api.IRoutingRule=} [properties] Properties to set + */ + function RoutingRule(properties) { + this.routingParameters = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RoutingRule routingParameters. + * @member {Array.} routingParameters + * @memberof google.api.RoutingRule + * @instance + */ + RoutingRule.prototype.routingParameters = $util.emptyArray; + + /** + * Creates a new RoutingRule instance using the specified properties. + * @function create + * @memberof google.api.RoutingRule + * @static + * @param {google.api.IRoutingRule=} [properties] Properties to set + * @returns {google.api.RoutingRule} RoutingRule instance + */ + RoutingRule.create = function create(properties) { + return new RoutingRule(properties); + }; + + /** + * Encodes the specified RoutingRule message. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @function encode + * @memberof google.api.RoutingRule + * @static + * @param {google.api.IRoutingRule} message RoutingRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingRule.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.routingParameters != null && message.routingParameters.length) + for (var i = 0; i < message.routingParameters.length; ++i) + $root.google.api.RoutingParameter.encode(message.routingParameters[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RoutingRule message, length delimited. Does not implicitly {@link google.api.RoutingRule.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.RoutingRule + * @static + * @param {google.api.IRoutingRule} message RoutingRule message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingRule.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RoutingRule message from the specified reader or buffer. + * @function decode + * @memberof google.api.RoutingRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.RoutingRule} RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingRule.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.RoutingRule(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.routingParameters && message.routingParameters.length)) + message.routingParameters = []; + message.routingParameters.push($root.google.api.RoutingParameter.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RoutingRule message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.RoutingRule + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.RoutingRule} RoutingRule + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingRule.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RoutingRule message. + * @function verify + * @memberof google.api.RoutingRule + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RoutingRule.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.routingParameters != null && message.hasOwnProperty("routingParameters")) { + if (!Array.isArray(message.routingParameters)) + return "routingParameters: array expected"; + for (var i = 0; i < message.routingParameters.length; ++i) { + var error = $root.google.api.RoutingParameter.verify(message.routingParameters[i]); + if (error) + return "routingParameters." + error; + } + } + return null; + }; + + /** + * Creates a RoutingRule message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.RoutingRule + * @static + * @param {Object.} object Plain object + * @returns {google.api.RoutingRule} RoutingRule + */ + RoutingRule.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.RoutingRule) + return object; + var message = new $root.google.api.RoutingRule(); + if (object.routingParameters) { + if (!Array.isArray(object.routingParameters)) + throw TypeError(".google.api.RoutingRule.routingParameters: array expected"); + message.routingParameters = []; + for (var i = 0; i < object.routingParameters.length; ++i) { + if (typeof object.routingParameters[i] !== "object") + throw TypeError(".google.api.RoutingRule.routingParameters: object expected"); + message.routingParameters[i] = $root.google.api.RoutingParameter.fromObject(object.routingParameters[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a RoutingRule message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.RoutingRule + * @static + * @param {google.api.RoutingRule} message RoutingRule + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RoutingRule.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.routingParameters = []; + if (message.routingParameters && message.routingParameters.length) { + object.routingParameters = []; + for (var j = 0; j < message.routingParameters.length; ++j) + object.routingParameters[j] = $root.google.api.RoutingParameter.toObject(message.routingParameters[j], options); + } + return object; + }; + + /** + * Converts this RoutingRule to JSON. + * @function toJSON + * @memberof google.api.RoutingRule + * @instance + * @returns {Object.} JSON object + */ + RoutingRule.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RoutingRule + * @function getTypeUrl + * @memberof google.api.RoutingRule + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoutingRule.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.RoutingRule"; + }; + + return RoutingRule; + })(); + + api.RoutingParameter = (function() { + + /** + * Properties of a RoutingParameter. + * @memberof google.api + * @interface IRoutingParameter + * @property {string|null} [field] RoutingParameter field + * @property {string|null} [pathTemplate] RoutingParameter pathTemplate + */ + + /** + * Constructs a new RoutingParameter. + * @memberof google.api + * @classdesc Represents a RoutingParameter. + * @implements IRoutingParameter + * @constructor + * @param {google.api.IRoutingParameter=} [properties] Properties to set + */ + function RoutingParameter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * RoutingParameter field. + * @member {string} field + * @memberof google.api.RoutingParameter + * @instance + */ + RoutingParameter.prototype.field = ""; + + /** + * RoutingParameter pathTemplate. + * @member {string} pathTemplate + * @memberof google.api.RoutingParameter + * @instance + */ + RoutingParameter.prototype.pathTemplate = ""; + + /** + * Creates a new RoutingParameter instance using the specified properties. + * @function create + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.IRoutingParameter=} [properties] Properties to set + * @returns {google.api.RoutingParameter} RoutingParameter instance + */ + RoutingParameter.create = function create(properties) { + return new RoutingParameter(properties); + }; + + /** + * Encodes the specified RoutingParameter message. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @function encode + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.IRoutingParameter} message RoutingParameter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingParameter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.field != null && Object.hasOwnProperty.call(message, "field")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.field); + if (message.pathTemplate != null && Object.hasOwnProperty.call(message, "pathTemplate")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.pathTemplate); + return writer; + }; + + /** + * Encodes the specified RoutingParameter message, length delimited. Does not implicitly {@link google.api.RoutingParameter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.IRoutingParameter} message RoutingParameter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RoutingParameter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer. + * @function decode + * @memberof google.api.RoutingParameter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.api.RoutingParameter} RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingParameter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.api.RoutingParameter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.field = reader.string(); + break; + } + case 2: { + message.pathTemplate = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RoutingParameter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.api.RoutingParameter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.api.RoutingParameter} RoutingParameter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RoutingParameter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RoutingParameter message. + * @function verify + * @memberof google.api.RoutingParameter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RoutingParameter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.field != null && message.hasOwnProperty("field")) + if (!$util.isString(message.field)) + return "field: string expected"; + if (message.pathTemplate != null && message.hasOwnProperty("pathTemplate")) + if (!$util.isString(message.pathTemplate)) + return "pathTemplate: string expected"; + return null; + }; + + /** + * Creates a RoutingParameter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.api.RoutingParameter + * @static + * @param {Object.} object Plain object + * @returns {google.api.RoutingParameter} RoutingParameter + */ + RoutingParameter.fromObject = function fromObject(object) { + if (object instanceof $root.google.api.RoutingParameter) + return object; + var message = new $root.google.api.RoutingParameter(); + if (object.field != null) + message.field = String(object.field); + if (object.pathTemplate != null) + message.pathTemplate = String(object.pathTemplate); + return message; + }; + + /** + * Creates a plain object from a RoutingParameter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.api.RoutingParameter + * @static + * @param {google.api.RoutingParameter} message RoutingParameter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RoutingParameter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.field = ""; + object.pathTemplate = ""; + } + if (message.field != null && message.hasOwnProperty("field")) + object.field = message.field; + if (message.pathTemplate != null && message.hasOwnProperty("pathTemplate")) + object.pathTemplate = message.pathTemplate; + return object; + }; + + /** + * Converts this RoutingParameter to JSON. + * @function toJSON + * @memberof google.api.RoutingParameter + * @instance + * @returns {Object.} JSON object + */ + RoutingParameter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RoutingParameter + * @function getTypeUrl + * @memberof google.api.RoutingParameter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RoutingParameter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.api.RoutingParameter"; + }; + + return RoutingParameter; + })(); + + return api; + })(); + + google.protobuf = (function() { + + /** + * Namespace protobuf. + * @memberof google + * @namespace + */ + var protobuf = {}; + + protobuf.FileDescriptorSet = (function() { + + /** + * Properties of a FileDescriptorSet. + * @memberof google.protobuf + * @interface IFileDescriptorSet + * @property {Array.|null} [file] FileDescriptorSet file + */ + + /** + * Constructs a new FileDescriptorSet. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorSet. + * @implements IFileDescriptorSet + * @constructor + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + */ + function FileDescriptorSet(properties) { + this.file = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorSet file. + * @member {Array.} file + * @memberof google.protobuf.FileDescriptorSet + * @instance + */ + FileDescriptorSet.prototype.file = $util.emptyArray; + + /** + * Creates a new FileDescriptorSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet instance + */ + FileDescriptorSet.create = function create(properties) { + return new FileDescriptorSet(properties); + }; + + /** + * Encodes the specified FileDescriptorSet message. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.file != null && message.file.length) + for (var i = 0; i < message.file.length; ++i) + $root.google.protobuf.FileDescriptorProto.encode(message.file[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FileDescriptorSet message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.IFileDescriptorSet} message FileDescriptorSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.file && message.file.length)) + message.file = []; + message.file.push($root.google.protobuf.FileDescriptorProto.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileDescriptorSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileDescriptorSet message. + * @function verify + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.file != null && message.hasOwnProperty("file")) { + if (!Array.isArray(message.file)) + return "file: array expected"; + for (var i = 0; i < message.file.length; ++i) { + var error = $root.google.protobuf.FileDescriptorProto.verify(message.file[i]); + if (error) + return "file." + error; + } + } + return null; + }; + + /** + * Creates a FileDescriptorSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorSet} FileDescriptorSet + */ + FileDescriptorSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorSet) + return object; + var message = new $root.google.protobuf.FileDescriptorSet(); + if (object.file) { + if (!Array.isArray(object.file)) + throw TypeError(".google.protobuf.FileDescriptorSet.file: array expected"); + message.file = []; + for (var i = 0; i < object.file.length; ++i) { + if (typeof object.file[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorSet.file: object expected"); + message.file[i] = $root.google.protobuf.FileDescriptorProto.fromObject(object.file[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileDescriptorSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {google.protobuf.FileDescriptorSet} message FileDescriptorSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.file = []; + if (message.file && message.file.length) { + object.file = []; + for (var j = 0; j < message.file.length; ++j) + object.file[j] = $root.google.protobuf.FileDescriptorProto.toObject(message.file[j], options); + } + return object; + }; + + /** + * Converts this FileDescriptorSet to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorSet + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FileDescriptorSet + * @function getTypeUrl + * @memberof google.protobuf.FileDescriptorSet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FileDescriptorSet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileDescriptorSet"; + }; + + return FileDescriptorSet; + })(); + + /** + * Edition enum. + * @name google.protobuf.Edition + * @enum {number} + * @property {number} EDITION_UNKNOWN=0 EDITION_UNKNOWN value + * @property {number} EDITION_LEGACY=900 EDITION_LEGACY value + * @property {number} EDITION_PROTO2=998 EDITION_PROTO2 value + * @property {number} EDITION_PROTO3=999 EDITION_PROTO3 value + * @property {number} EDITION_2023=1000 EDITION_2023 value + * @property {number} EDITION_2024=1001 EDITION_2024 value + * @property {number} EDITION_1_TEST_ONLY=1 EDITION_1_TEST_ONLY value + * @property {number} EDITION_2_TEST_ONLY=2 EDITION_2_TEST_ONLY value + * @property {number} EDITION_99997_TEST_ONLY=99997 EDITION_99997_TEST_ONLY value + * @property {number} EDITION_99998_TEST_ONLY=99998 EDITION_99998_TEST_ONLY value + * @property {number} EDITION_99999_TEST_ONLY=99999 EDITION_99999_TEST_ONLY value + * @property {number} EDITION_MAX=2147483647 EDITION_MAX value + */ + protobuf.Edition = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "EDITION_UNKNOWN"] = 0; + values[valuesById[900] = "EDITION_LEGACY"] = 900; + values[valuesById[998] = "EDITION_PROTO2"] = 998; + values[valuesById[999] = "EDITION_PROTO3"] = 999; + values[valuesById[1000] = "EDITION_2023"] = 1000; + values[valuesById[1001] = "EDITION_2024"] = 1001; + values[valuesById[1] = "EDITION_1_TEST_ONLY"] = 1; + values[valuesById[2] = "EDITION_2_TEST_ONLY"] = 2; + values[valuesById[99997] = "EDITION_99997_TEST_ONLY"] = 99997; + values[valuesById[99998] = "EDITION_99998_TEST_ONLY"] = 99998; + values[valuesById[99999] = "EDITION_99999_TEST_ONLY"] = 99999; + values[valuesById[2147483647] = "EDITION_MAX"] = 2147483647; + return values; + })(); + + protobuf.FileDescriptorProto = (function() { + + /** + * Properties of a FileDescriptorProto. + * @memberof google.protobuf + * @interface IFileDescriptorProto + * @property {string|null} [name] FileDescriptorProto name + * @property {string|null} ["package"] FileDescriptorProto package + * @property {Array.|null} [dependency] FileDescriptorProto dependency + * @property {Array.|null} [publicDependency] FileDescriptorProto publicDependency + * @property {Array.|null} [weakDependency] FileDescriptorProto weakDependency + * @property {Array.|null} [optionDependency] FileDescriptorProto optionDependency + * @property {Array.|null} [messageType] FileDescriptorProto messageType + * @property {Array.|null} [enumType] FileDescriptorProto enumType + * @property {Array.|null} [service] FileDescriptorProto service + * @property {Array.|null} [extension] FileDescriptorProto extension + * @property {google.protobuf.IFileOptions|null} [options] FileDescriptorProto options + * @property {google.protobuf.ISourceCodeInfo|null} [sourceCodeInfo] FileDescriptorProto sourceCodeInfo + * @property {string|null} [syntax] FileDescriptorProto syntax + * @property {google.protobuf.Edition|null} [edition] FileDescriptorProto edition + */ + + /** + * Constructs a new FileDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FileDescriptorProto. + * @implements IFileDescriptorProto + * @constructor + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + */ + function FileDescriptorProto(properties) { + this.dependency = []; + this.publicDependency = []; + this.weakDependency = []; + this.optionDependency = []; + this.messageType = []; + this.enumType = []; + this.service = []; + this.extension = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.name = ""; + + /** + * FileDescriptorProto package. + * @member {string} package + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype["package"] = ""; + + /** + * FileDescriptorProto dependency. + * @member {Array.} dependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.dependency = $util.emptyArray; + + /** + * FileDescriptorProto publicDependency. + * @member {Array.} publicDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.publicDependency = $util.emptyArray; + + /** + * FileDescriptorProto weakDependency. + * @member {Array.} weakDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.weakDependency = $util.emptyArray; + + /** + * FileDescriptorProto optionDependency. + * @member {Array.} optionDependency + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.optionDependency = $util.emptyArray; + + /** + * FileDescriptorProto messageType. + * @member {Array.} messageType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.messageType = $util.emptyArray; + + /** + * FileDescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * FileDescriptorProto service. + * @member {Array.} service + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.service = $util.emptyArray; + + /** + * FileDescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.extension = $util.emptyArray; + + /** + * FileDescriptorProto options. + * @member {google.protobuf.IFileOptions|null|undefined} options + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.options = null; + + /** + * FileDescriptorProto sourceCodeInfo. + * @member {google.protobuf.ISourceCodeInfo|null|undefined} sourceCodeInfo + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.sourceCodeInfo = null; + + /** + * FileDescriptorProto syntax. + * @member {string} syntax + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.syntax = ""; + + /** + * FileDescriptorProto edition. + * @member {google.protobuf.Edition} edition + * @memberof google.protobuf.FileDescriptorProto + * @instance + */ + FileDescriptorProto.prototype.edition = 0; + + /** + * Creates a new FileDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto instance + */ + FileDescriptorProto.create = function create(properties) { + return new FileDescriptorProto(properties); + }; + + /** + * Encodes the specified FileDescriptorProto message. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message["package"] != null && Object.hasOwnProperty.call(message, "package")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message["package"]); + if (message.dependency != null && message.dependency.length) + for (var i = 0; i < message.dependency.length; ++i) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.dependency[i]); + if (message.messageType != null && message.messageType.length) + for (var i = 0; i < message.messageType.length; ++i) + $root.google.protobuf.DescriptorProto.encode(message.messageType[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode(message.enumType[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.service != null && message.service.length) + for (var i = 0; i < message.service.length; ++i) + $root.google.protobuf.ServiceDescriptorProto.encode(message.service[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.FileOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.sourceCodeInfo != null && Object.hasOwnProperty.call(message, "sourceCodeInfo")) + $root.google.protobuf.SourceCodeInfo.encode(message.sourceCodeInfo, writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.publicDependency != null && message.publicDependency.length) + for (var i = 0; i < message.publicDependency.length; ++i) + writer.uint32(/* id 10, wireType 0 =*/80).int32(message.publicDependency[i]); + if (message.weakDependency != null && message.weakDependency.length) + for (var i = 0; i < message.weakDependency.length; ++i) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.weakDependency[i]); + if (message.syntax != null && Object.hasOwnProperty.call(message, "syntax")) + writer.uint32(/* id 12, wireType 2 =*/98).string(message.syntax); + if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) + writer.uint32(/* id 14, wireType 0 =*/112).int32(message.edition); + if (message.optionDependency != null && message.optionDependency.length) + for (var i = 0; i < message.optionDependency.length; ++i) + writer.uint32(/* id 15, wireType 2 =*/122).string(message.optionDependency[i]); + return writer; + }; + + /** + * Encodes the specified FileDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FileDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.IFileDescriptorProto} message FileDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message["package"] = reader.string(); + break; + } + case 3: { + if (!(message.dependency && message.dependency.length)) + message.dependency = []; + message.dependency.push(reader.string()); + break; + } + case 10: { + if (!(message.publicDependency && message.publicDependency.length)) + message.publicDependency = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.publicDependency.push(reader.int32()); + } else + message.publicDependency.push(reader.int32()); + break; + } + case 11: { + if (!(message.weakDependency && message.weakDependency.length)) + message.weakDependency = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.weakDependency.push(reader.int32()); + } else + message.weakDependency.push(reader.int32()); + break; + } + case 15: { + if (!(message.optionDependency && message.optionDependency.length)) + message.optionDependency = []; + message.optionDependency.push(reader.string()); + break; + } + case 4: { + if (!(message.messageType && message.messageType.length)) + message.messageType = []; + message.messageType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); + break; + } + case 5: { + if (!(message.enumType && message.enumType.length)) + message.enumType = []; + message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 6: { + if (!(message.service && message.service.length)) + message.service = []; + message.service.push($root.google.protobuf.ServiceDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 7: { + if (!(message.extension && message.extension.length)) + message.extension = []; + message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 8: { + message.options = $root.google.protobuf.FileOptions.decode(reader, reader.uint32()); + break; + } + case 9: { + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.decode(reader, reader.uint32()); + break; + } + case 12: { + message.syntax = reader.string(); + break; + } + case 14: { + message.edition = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileDescriptorProto message. + * @function verify + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message["package"] != null && message.hasOwnProperty("package")) + if (!$util.isString(message["package"])) + return "package: string expected"; + if (message.dependency != null && message.hasOwnProperty("dependency")) { + if (!Array.isArray(message.dependency)) + return "dependency: array expected"; + for (var i = 0; i < message.dependency.length; ++i) + if (!$util.isString(message.dependency[i])) + return "dependency: string[] expected"; + } + if (message.publicDependency != null && message.hasOwnProperty("publicDependency")) { + if (!Array.isArray(message.publicDependency)) + return "publicDependency: array expected"; + for (var i = 0; i < message.publicDependency.length; ++i) + if (!$util.isInteger(message.publicDependency[i])) + return "publicDependency: integer[] expected"; + } + if (message.weakDependency != null && message.hasOwnProperty("weakDependency")) { + if (!Array.isArray(message.weakDependency)) + return "weakDependency: array expected"; + for (var i = 0; i < message.weakDependency.length; ++i) + if (!$util.isInteger(message.weakDependency[i])) + return "weakDependency: integer[] expected"; + } + if (message.optionDependency != null && message.hasOwnProperty("optionDependency")) { + if (!Array.isArray(message.optionDependency)) + return "optionDependency: array expected"; + for (var i = 0; i < message.optionDependency.length; ++i) + if (!$util.isString(message.optionDependency[i])) + return "optionDependency: string[] expected"; + } + if (message.messageType != null && message.hasOwnProperty("messageType")) { + if (!Array.isArray(message.messageType)) + return "messageType: array expected"; + for (var i = 0; i < message.messageType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify(message.messageType[i]); + if (error) + return "messageType." + error; + } + } + if (message.enumType != null && message.hasOwnProperty("enumType")) { + if (!Array.isArray(message.enumType)) + return "enumType: array expected"; + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify(message.enumType[i]); + if (error) + return "enumType." + error; + } + } + if (message.service != null && message.hasOwnProperty("service")) { + if (!Array.isArray(message.service)) + return "service: array expected"; + for (var i = 0; i < message.service.length; ++i) { + var error = $root.google.protobuf.ServiceDescriptorProto.verify(message.service[i]); + if (error) + return "service." + error; + } + } + if (message.extension != null && message.hasOwnProperty("extension")) { + if (!Array.isArray(message.extension)) + return "extension: array expected"; + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify(message.extension[i]); + if (error) + return "extension." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.FileOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) { + var error = $root.google.protobuf.SourceCodeInfo.verify(message.sourceCodeInfo); + if (error) + return "sourceCodeInfo." + error; + } + if (message.syntax != null && message.hasOwnProperty("syntax")) + if (!$util.isString(message.syntax)) + return "syntax: string expected"; + if (message.edition != null && message.hasOwnProperty("edition")) + switch (message.edition) { + default: + return "edition: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FileDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileDescriptorProto} FileDescriptorProto + */ + FileDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileDescriptorProto) + return object; + var message = new $root.google.protobuf.FileDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object["package"] != null) + message["package"] = String(object["package"]); + if (object.dependency) { + if (!Array.isArray(object.dependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.dependency: array expected"); + message.dependency = []; + for (var i = 0; i < object.dependency.length; ++i) + message.dependency[i] = String(object.dependency[i]); + } + if (object.publicDependency) { + if (!Array.isArray(object.publicDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.publicDependency: array expected"); + message.publicDependency = []; + for (var i = 0; i < object.publicDependency.length; ++i) + message.publicDependency[i] = object.publicDependency[i] | 0; + } + if (object.weakDependency) { + if (!Array.isArray(object.weakDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.weakDependency: array expected"); + message.weakDependency = []; + for (var i = 0; i < object.weakDependency.length; ++i) + message.weakDependency[i] = object.weakDependency[i] | 0; + } + if (object.optionDependency) { + if (!Array.isArray(object.optionDependency)) + throw TypeError(".google.protobuf.FileDescriptorProto.optionDependency: array expected"); + message.optionDependency = []; + for (var i = 0; i < object.optionDependency.length; ++i) + message.optionDependency[i] = String(object.optionDependency[i]); + } + if (object.messageType) { + if (!Array.isArray(object.messageType)) + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: array expected"); + message.messageType = []; + for (var i = 0; i < object.messageType.length; ++i) { + if (typeof object.messageType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.messageType: object expected"); + message.messageType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.messageType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.service) { + if (!Array.isArray(object.service)) + throw TypeError(".google.protobuf.FileDescriptorProto.service: array expected"); + message.service = []; + for (var i = 0; i < object.service.length; ++i) { + if (typeof object.service[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.service: object expected"); + message.service[i] = $root.google.protobuf.ServiceDescriptorProto.fromObject(object.service[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.FileDescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FileOptions.fromObject(object.options); + } + if (object.sourceCodeInfo != null) { + if (typeof object.sourceCodeInfo !== "object") + throw TypeError(".google.protobuf.FileDescriptorProto.sourceCodeInfo: object expected"); + message.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.fromObject(object.sourceCodeInfo); + } + if (object.syntax != null) + message.syntax = String(object.syntax); + switch (object.edition) { + default: + if (typeof object.edition === "number") { + message.edition = object.edition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.edition = 0; + break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + return message; + }; + + /** + * Creates a plain object from a FileDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {google.protobuf.FileDescriptorProto} message FileDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.dependency = []; + object.messageType = []; + object.enumType = []; + object.service = []; + object.extension = []; + object.publicDependency = []; + object.weakDependency = []; + object.optionDependency = []; + } + if (options.defaults) { + object.name = ""; + object["package"] = ""; + object.options = null; + object.sourceCodeInfo = null; + object.syntax = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message["package"] != null && message.hasOwnProperty("package")) + object["package"] = message["package"]; + if (message.dependency && message.dependency.length) { + object.dependency = []; + for (var j = 0; j < message.dependency.length; ++j) + object.dependency[j] = message.dependency[j]; + } + if (message.messageType && message.messageType.length) { + object.messageType = []; + for (var j = 0; j < message.messageType.length; ++j) + object.messageType[j] = $root.google.protobuf.DescriptorProto.toObject(message.messageType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.service && message.service.length) { + object.service = []; + for (var j = 0; j < message.service.length; ++j) + object.service[j] = $root.google.protobuf.ServiceDescriptorProto.toObject(message.service[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FileOptions.toObject(message.options, options); + if (message.sourceCodeInfo != null && message.hasOwnProperty("sourceCodeInfo")) + object.sourceCodeInfo = $root.google.protobuf.SourceCodeInfo.toObject(message.sourceCodeInfo, options); + if (message.publicDependency && message.publicDependency.length) { + object.publicDependency = []; + for (var j = 0; j < message.publicDependency.length; ++j) + object.publicDependency[j] = message.publicDependency[j]; + } + if (message.weakDependency && message.weakDependency.length) { + object.weakDependency = []; + for (var j = 0; j < message.weakDependency.length; ++j) + object.weakDependency[j] = message.weakDependency[j]; + } + if (message.syntax != null && message.hasOwnProperty("syntax")) + object.syntax = message.syntax; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.optionDependency && message.optionDependency.length) { + object.optionDependency = []; + for (var j = 0; j < message.optionDependency.length; ++j) + object.optionDependency[j] = message.optionDependency[j]; + } + return object; + }; + + /** + * Converts this FileDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FileDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FileDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FileDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.FileDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FileDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileDescriptorProto"; + }; + + return FileDescriptorProto; + })(); + + protobuf.DescriptorProto = (function() { + + /** + * Properties of a DescriptorProto. + * @memberof google.protobuf + * @interface IDescriptorProto + * @property {string|null} [name] DescriptorProto name + * @property {Array.|null} [field] DescriptorProto field + * @property {Array.|null} [extension] DescriptorProto extension + * @property {Array.|null} [nestedType] DescriptorProto nestedType + * @property {Array.|null} [enumType] DescriptorProto enumType + * @property {Array.|null} [extensionRange] DescriptorProto extensionRange + * @property {Array.|null} [oneofDecl] DescriptorProto oneofDecl + * @property {google.protobuf.IMessageOptions|null} [options] DescriptorProto options + * @property {Array.|null} [reservedRange] DescriptorProto reservedRange + * @property {Array.|null} [reservedName] DescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] DescriptorProto visibility + */ + + /** + * Constructs a new DescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a DescriptorProto. + * @implements IDescriptorProto + * @constructor + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + */ + function DescriptorProto(properties) { + this.field = []; + this.extension = []; + this.nestedType = []; + this.enumType = []; + this.extensionRange = []; + this.oneofDecl = []; + this.reservedRange = []; + this.reservedName = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DescriptorProto name. + * @member {string} name + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.name = ""; + + /** + * DescriptorProto field. + * @member {Array.} field + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.field = $util.emptyArray; + + /** + * DescriptorProto extension. + * @member {Array.} extension + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extension = $util.emptyArray; + + /** + * DescriptorProto nestedType. + * @member {Array.} nestedType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.nestedType = $util.emptyArray; + + /** + * DescriptorProto enumType. + * @member {Array.} enumType + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.enumType = $util.emptyArray; + + /** + * DescriptorProto extensionRange. + * @member {Array.} extensionRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.extensionRange = $util.emptyArray; + + /** + * DescriptorProto oneofDecl. + * @member {Array.} oneofDecl + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.oneofDecl = $util.emptyArray; + + /** + * DescriptorProto options. + * @member {google.protobuf.IMessageOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.options = null; + + /** + * DescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedRange = $util.emptyArray; + + /** + * DescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.reservedName = $util.emptyArray; + + /** + * DescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.DescriptorProto + * @instance + */ + DescriptorProto.prototype.visibility = 0; + + /** + * Creates a new DescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto} DescriptorProto instance + */ + DescriptorProto.create = function create(properties) { + return new DescriptorProto(properties); + }; + + /** + * Encodes the specified DescriptorProto message. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.field != null && message.field.length) + for (var i = 0; i < message.field.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode(message.field[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.nestedType != null && message.nestedType.length) + for (var i = 0; i < message.nestedType.length; ++i) + $root.google.protobuf.DescriptorProto.encode(message.nestedType[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.enumType != null && message.enumType.length) + for (var i = 0; i < message.enumType.length; ++i) + $root.google.protobuf.EnumDescriptorProto.encode(message.enumType[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.extensionRange != null && message.extensionRange.length) + for (var i = 0; i < message.extensionRange.length; ++i) + $root.google.protobuf.DescriptorProto.ExtensionRange.encode(message.extensionRange[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.extension != null && message.extension.length) + for (var i = 0; i < message.extension.length; ++i) + $root.google.protobuf.FieldDescriptorProto.encode(message.extension[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.MessageOptions.encode(message.options, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.oneofDecl != null && message.oneofDecl.length) + for (var i = 0; i < message.oneofDecl.length; ++i) + $root.google.protobuf.OneofDescriptorProto.encode(message.oneofDecl[i], writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.reservedRange != null && message.reservedRange.length) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.DescriptorProto.ReservedRange.encode(message.reservedRange[i], writer.uint32(/* id 9, wireType 2 =*/74).fork()).ldelim(); + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 11, wireType 0 =*/88).int32(message.visibility); + return writer; + }; + + /** + * Encodes the specified DescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.IDescriptorProto} message DescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (!(message.field && message.field.length)) + message.field = []; + message.field.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 6: { + if (!(message.extension && message.extension.length)) + message.extension = []; + message.extension.push($root.google.protobuf.FieldDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 3: { + if (!(message.nestedType && message.nestedType.length)) + message.nestedType = []; + message.nestedType.push($root.google.protobuf.DescriptorProto.decode(reader, reader.uint32())); + break; + } + case 4: { + if (!(message.enumType && message.enumType.length)) + message.enumType = []; + message.enumType.push($root.google.protobuf.EnumDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 5: { + if (!(message.extensionRange && message.extensionRange.length)) + message.extensionRange = []; + message.extensionRange.push($root.google.protobuf.DescriptorProto.ExtensionRange.decode(reader, reader.uint32())); + break; + } + case 8: { + if (!(message.oneofDecl && message.oneofDecl.length)) + message.oneofDecl = []; + message.oneofDecl.push($root.google.protobuf.OneofDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 7: { + message.options = $root.google.protobuf.MessageOptions.decode(reader, reader.uint32()); + break; + } + case 9: { + if (!(message.reservedRange && message.reservedRange.length)) + message.reservedRange = []; + message.reservedRange.push($root.google.protobuf.DescriptorProto.ReservedRange.decode(reader, reader.uint32())); + break; + } + case 10: { + if (!(message.reservedName && message.reservedName.length)) + message.reservedName = []; + message.reservedName.push(reader.string()); + break; + } + case 11: { + message.visibility = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto} DescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DescriptorProto message. + * @function verify + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.field != null && message.hasOwnProperty("field")) { + if (!Array.isArray(message.field)) + return "field: array expected"; + for (var i = 0; i < message.field.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify(message.field[i]); + if (error) + return "field." + error; + } + } + if (message.extension != null && message.hasOwnProperty("extension")) { + if (!Array.isArray(message.extension)) + return "extension: array expected"; + for (var i = 0; i < message.extension.length; ++i) { + var error = $root.google.protobuf.FieldDescriptorProto.verify(message.extension[i]); + if (error) + return "extension." + error; + } + } + if (message.nestedType != null && message.hasOwnProperty("nestedType")) { + if (!Array.isArray(message.nestedType)) + return "nestedType: array expected"; + for (var i = 0; i < message.nestedType.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.verify(message.nestedType[i]); + if (error) + return "nestedType." + error; + } + } + if (message.enumType != null && message.hasOwnProperty("enumType")) { + if (!Array.isArray(message.enumType)) + return "enumType: array expected"; + for (var i = 0; i < message.enumType.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.verify(message.enumType[i]); + if (error) + return "enumType." + error; + } + } + if (message.extensionRange != null && message.hasOwnProperty("extensionRange")) { + if (!Array.isArray(message.extensionRange)) + return "extensionRange: array expected"; + for (var i = 0; i < message.extensionRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ExtensionRange.verify(message.extensionRange[i]); + if (error) + return "extensionRange." + error; + } + } + if (message.oneofDecl != null && message.hasOwnProperty("oneofDecl")) { + if (!Array.isArray(message.oneofDecl)) + return "oneofDecl: array expected"; + for (var i = 0; i < message.oneofDecl.length; ++i) { + var error = $root.google.protobuf.OneofDescriptorProto.verify(message.oneofDecl[i]); + if (error) + return "oneofDecl." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.MessageOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.reservedRange != null && message.hasOwnProperty("reservedRange")) { + if (!Array.isArray(message.reservedRange)) + return "reservedRange: array expected"; + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.DescriptorProto.ReservedRange.verify(message.reservedRange[i]); + if (error) + return "reservedRange." + error; + } + } + if (message.reservedName != null && message.hasOwnProperty("reservedName")) { + if (!Array.isArray(message.reservedName)) + return "reservedName: array expected"; + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return "reservedName: string[] expected"; + } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates a DescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto} DescriptorProto + */ + DescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto) + return object; + var message = new $root.google.protobuf.DescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.field) { + if (!Array.isArray(object.field)) + throw TypeError(".google.protobuf.DescriptorProto.field: array expected"); + message.field = []; + for (var i = 0; i < object.field.length; ++i) { + if (typeof object.field[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.field: object expected"); + message.field[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.field[i]); + } + } + if (object.extension) { + if (!Array.isArray(object.extension)) + throw TypeError(".google.protobuf.DescriptorProto.extension: array expected"); + message.extension = []; + for (var i = 0; i < object.extension.length; ++i) { + if (typeof object.extension[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extension: object expected"); + message.extension[i] = $root.google.protobuf.FieldDescriptorProto.fromObject(object.extension[i]); + } + } + if (object.nestedType) { + if (!Array.isArray(object.nestedType)) + throw TypeError(".google.protobuf.DescriptorProto.nestedType: array expected"); + message.nestedType = []; + for (var i = 0; i < object.nestedType.length; ++i) { + if (typeof object.nestedType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.nestedType: object expected"); + message.nestedType[i] = $root.google.protobuf.DescriptorProto.fromObject(object.nestedType[i]); + } + } + if (object.enumType) { + if (!Array.isArray(object.enumType)) + throw TypeError(".google.protobuf.DescriptorProto.enumType: array expected"); + message.enumType = []; + for (var i = 0; i < object.enumType.length; ++i) { + if (typeof object.enumType[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.enumType: object expected"); + message.enumType[i] = $root.google.protobuf.EnumDescriptorProto.fromObject(object.enumType[i]); + } + } + if (object.extensionRange) { + if (!Array.isArray(object.extensionRange)) + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: array expected"); + message.extensionRange = []; + for (var i = 0; i < object.extensionRange.length; ++i) { + if (typeof object.extensionRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.extensionRange: object expected"); + message.extensionRange[i] = $root.google.protobuf.DescriptorProto.ExtensionRange.fromObject(object.extensionRange[i]); + } + } + if (object.oneofDecl) { + if (!Array.isArray(object.oneofDecl)) + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: array expected"); + message.oneofDecl = []; + for (var i = 0; i < object.oneofDecl.length; ++i) { + if (typeof object.oneofDecl[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.oneofDecl: object expected"); + message.oneofDecl[i] = $root.google.protobuf.OneofDescriptorProto.fromObject(object.oneofDecl[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.DescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MessageOptions.fromObject(object.options); + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: array expected"); + message.reservedRange = []; + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== "object") + throw TypeError(".google.protobuf.DescriptorProto.reservedRange: object expected"); + message.reservedRange[i] = $root.google.protobuf.DescriptorProto.ReservedRange.fromObject(object.reservedRange[i]); + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError(".google.protobuf.DescriptorProto.reservedName: array expected"); + message.reservedName = []; + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]); + } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from a DescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto + * @static + * @param {google.protobuf.DescriptorProto} message DescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.field = []; + object.nestedType = []; + object.enumType = []; + object.extensionRange = []; + object.extension = []; + object.oneofDecl = []; + object.reservedRange = []; + object.reservedName = []; + } + if (options.defaults) { + object.name = ""; + object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.field && message.field.length) { + object.field = []; + for (var j = 0; j < message.field.length; ++j) + object.field[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.field[j], options); + } + if (message.nestedType && message.nestedType.length) { + object.nestedType = []; + for (var j = 0; j < message.nestedType.length; ++j) + object.nestedType[j] = $root.google.protobuf.DescriptorProto.toObject(message.nestedType[j], options); + } + if (message.enumType && message.enumType.length) { + object.enumType = []; + for (var j = 0; j < message.enumType.length; ++j) + object.enumType[j] = $root.google.protobuf.EnumDescriptorProto.toObject(message.enumType[j], options); + } + if (message.extensionRange && message.extensionRange.length) { + object.extensionRange = []; + for (var j = 0; j < message.extensionRange.length; ++j) + object.extensionRange[j] = $root.google.protobuf.DescriptorProto.ExtensionRange.toObject(message.extensionRange[j], options); + } + if (message.extension && message.extension.length) { + object.extension = []; + for (var j = 0; j < message.extension.length; ++j) + object.extension[j] = $root.google.protobuf.FieldDescriptorProto.toObject(message.extension[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MessageOptions.toObject(message.options, options); + if (message.oneofDecl && message.oneofDecl.length) { + object.oneofDecl = []; + for (var j = 0; j < message.oneofDecl.length; ++j) + object.oneofDecl[j] = $root.google.protobuf.OneofDescriptorProto.toObject(message.oneofDecl[j], options); + } + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = []; + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[j] = $root.google.protobuf.DescriptorProto.ReservedRange.toObject(message.reservedRange[j], options); + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = []; + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j]; + } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; + return object; + }; + + /** + * Converts this DescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto + * @instance + * @returns {Object.} JSON object + */ + DescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.DescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto"; + }; + + DescriptorProto.ExtensionRange = (function() { + + /** + * Properties of an ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @interface IExtensionRange + * @property {number|null} [start] ExtensionRange start + * @property {number|null} [end] ExtensionRange end + * @property {google.protobuf.IExtensionRangeOptions|null} [options] ExtensionRange options + */ + + /** + * Constructs a new ExtensionRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents an ExtensionRange. + * @implements IExtensionRange + * @constructor + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + */ + function ExtensionRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtensionRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.start = 0; + + /** + * ExtensionRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.end = 0; + + /** + * ExtensionRange options. + * @member {google.protobuf.IExtensionRangeOptions|null|undefined} options + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + */ + ExtensionRange.prototype.options = null; + + /** + * Creates a new ExtensionRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange instance + */ + ExtensionRange.create = function create(properties) { + return new ExtensionRange(properties); + }; + + /** + * Encodes the specified ExtensionRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.start != null && Object.hasOwnProperty.call(message, "start")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); + if (message.end != null && Object.hasOwnProperty.call(message, "end")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.ExtensionRangeOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExtensionRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ExtensionRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.IExtensionRange} message ExtensionRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DescriptorProto.ExtensionRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.start = reader.int32(); + break; + } + case 2: { + message.end = reader.int32(); + break; + } + case 3: { + message.options = $root.google.protobuf.ExtensionRangeOptions.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExtensionRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExtensionRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.start != null && message.hasOwnProperty("start")) + if (!$util.isInteger(message.start)) + return "start: integer expected"; + if (message.end != null && message.hasOwnProperty("end")) + if (!$util.isInteger(message.end)) + return "end: integer expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.ExtensionRangeOptions.verify(message.options); + if (error) + return "options." + error; + } + return null; + }; + + /** + * Creates an ExtensionRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ExtensionRange} ExtensionRange + */ + ExtensionRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ExtensionRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ExtensionRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.DescriptorProto.ExtensionRange.options: object expected"); + message.options = $root.google.protobuf.ExtensionRangeOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an ExtensionRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {google.protobuf.DescriptorProto.ExtensionRange} message ExtensionRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + object.options = null; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.ExtensionRangeOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this ExtensionRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @instance + * @returns {Object.} JSON object + */ + ExtensionRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExtensionRange + * @function getTypeUrl + * @memberof google.protobuf.DescriptorProto.ExtensionRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExtensionRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto.ExtensionRange"; + }; + + return ExtensionRange; + })(); + + DescriptorProto.ReservedRange = (function() { + + /** + * Properties of a ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @interface IReservedRange + * @property {number|null} [start] ReservedRange start + * @property {number|null} [end] ReservedRange end + */ + + /** + * Constructs a new ReservedRange. + * @memberof google.protobuf.DescriptorProto + * @classdesc Represents a ReservedRange. + * @implements IReservedRange + * @constructor + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + */ + function ReservedRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ReservedRange start. + * @member {number} start + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.start = 0; + + /** + * ReservedRange end. + * @member {number} end + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + */ + ReservedRange.prototype.end = 0; + + /** + * Creates a new ReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange=} [properties] Properties to set + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange instance + */ + ReservedRange.create = function create(properties) { + return new ReservedRange(properties); + }; + + /** + * Encodes the specified ReservedRange message. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.start != null && Object.hasOwnProperty.call(message, "start")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); + if (message.end != null && Object.hasOwnProperty.call(message, "end")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); + return writer; + }; + + /** + * Encodes the specified ReservedRange message, length delimited. Does not implicitly {@link google.protobuf.DescriptorProto.ReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.IReservedRange} message ReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ReservedRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DescriptorProto.ReservedRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.start = reader.int32(); + break; + } + case 2: { + message.end = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ReservedRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ReservedRange message. + * @function verify + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ReservedRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.start != null && message.hasOwnProperty("start")) + if (!$util.isInteger(message.start)) + return "start: integer expected"; + if (message.end != null && message.hasOwnProperty("end")) + if (!$util.isInteger(message.end)) + return "end: integer expected"; + return null; + }; + + /** + * Creates a ReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DescriptorProto.ReservedRange} ReservedRange + */ + ReservedRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DescriptorProto.ReservedRange) + return object; + var message = new $root.google.protobuf.DescriptorProto.ReservedRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from a ReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {google.protobuf.DescriptorProto.ReservedRange} message ReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ReservedRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this ReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @instance + * @returns {Object.} JSON object + */ + ReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ReservedRange + * @function getTypeUrl + * @memberof google.protobuf.DescriptorProto.ReservedRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ReservedRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DescriptorProto.ReservedRange"; + }; + + return ReservedRange; + })(); + + return DescriptorProto; + })(); + + protobuf.ExtensionRangeOptions = (function() { + + /** + * Properties of an ExtensionRangeOptions. + * @memberof google.protobuf + * @interface IExtensionRangeOptions + * @property {Array.|null} [uninterpretedOption] ExtensionRangeOptions uninterpretedOption + * @property {Array.|null} [declaration] ExtensionRangeOptions declaration + * @property {google.protobuf.IFeatureSet|null} [features] ExtensionRangeOptions features + * @property {google.protobuf.ExtensionRangeOptions.VerificationState|null} [verification] ExtensionRangeOptions verification + */ + + /** + * Constructs a new ExtensionRangeOptions. + * @memberof google.protobuf + * @classdesc Represents an ExtensionRangeOptions. + * @implements IExtensionRangeOptions + * @constructor + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + */ + function ExtensionRangeOptions(properties) { + this.uninterpretedOption = []; + this.declaration = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ExtensionRangeOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + */ + ExtensionRangeOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * ExtensionRangeOptions declaration. + * @member {Array.} declaration + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + */ + ExtensionRangeOptions.prototype.declaration = $util.emptyArray; + + /** + * ExtensionRangeOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + */ + ExtensionRangeOptions.prototype.features = null; + + /** + * ExtensionRangeOptions verification. + * @member {google.protobuf.ExtensionRangeOptions.VerificationState} verification + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + */ + ExtensionRangeOptions.prototype.verification = 1; + + /** + * Creates a new ExtensionRangeOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions=} [properties] Properties to set + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions instance + */ + ExtensionRangeOptions.create = function create(properties) { + return new ExtensionRangeOptions(properties); + }; + + /** + * Encodes the specified ExtensionRangeOptions message. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.declaration != null && message.declaration.length) + for (var i = 0; i < message.declaration.length; ++i) + $root.google.protobuf.ExtensionRangeOptions.Declaration.encode(message.declaration[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.verification != null && Object.hasOwnProperty.call(message, "verification")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.verification); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 50, wireType 2 =*/402).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ExtensionRangeOptions message, length delimited. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.IExtensionRangeOptions} message ExtensionRangeOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ExtensionRangeOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ExtensionRangeOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 2: { + if (!(message.declaration && message.declaration.length)) + message.declaration = []; + message.declaration.push($root.google.protobuf.ExtensionRangeOptions.Declaration.decode(reader, reader.uint32())); + break; + } + case 50: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 3: { + message.verification = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ExtensionRangeOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ExtensionRangeOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ExtensionRangeOptions message. + * @function verify + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ExtensionRangeOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + if (message.declaration != null && message.hasOwnProperty("declaration")) { + if (!Array.isArray(message.declaration)) + return "declaration: array expected"; + for (var i = 0; i < message.declaration.length; ++i) { + var error = $root.google.protobuf.ExtensionRangeOptions.Declaration.verify(message.declaration[i]); + if (error) + return "declaration." + error; + } + } + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.verification != null && message.hasOwnProperty("verification")) + switch (message.verification) { + default: + return "verification: enum value expected"; + case 0: + case 1: + break; + } + return null; + }; + + /** + * Creates an ExtensionRangeOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ExtensionRangeOptions} ExtensionRangeOptions + */ + ExtensionRangeOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ExtensionRangeOptions) + return object; + var message = new $root.google.protobuf.ExtensionRangeOptions(); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.ExtensionRangeOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.ExtensionRangeOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object.declaration) { + if (!Array.isArray(object.declaration)) + throw TypeError(".google.protobuf.ExtensionRangeOptions.declaration: array expected"); + message.declaration = []; + for (var i = 0; i < object.declaration.length; ++i) { + if (typeof object.declaration[i] !== "object") + throw TypeError(".google.protobuf.ExtensionRangeOptions.declaration: object expected"); + message.declaration[i] = $root.google.protobuf.ExtensionRangeOptions.Declaration.fromObject(object.declaration[i]); + } + } + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.ExtensionRangeOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + switch (object.verification) { + case "DECLARATION": + case 0: + message.verification = 0; + break; + default: + if (typeof object.verification === "number") { + message.verification = object.verification; + break; + } + break; + case "UNVERIFIED": + case 1: + message.verification = 1; + break; + } + return message; + }; + + /** + * Creates a plain object from an ExtensionRangeOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {google.protobuf.ExtensionRangeOptions} message ExtensionRangeOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ExtensionRangeOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.declaration = []; + object.uninterpretedOption = []; + } + if (options.defaults) { + object.verification = options.enums === String ? "UNVERIFIED" : 1; + object.features = null; + } + if (message.declaration && message.declaration.length) { + object.declaration = []; + for (var j = 0; j < message.declaration.length; ++j) + object.declaration[j] = $root.google.protobuf.ExtensionRangeOptions.Declaration.toObject(message.declaration[j], options); + } + if (message.verification != null && message.hasOwnProperty("verification")) + object.verification = options.enums === String ? $root.google.protobuf.ExtensionRangeOptions.VerificationState[message.verification] === undefined ? message.verification : $root.google.protobuf.ExtensionRangeOptions.VerificationState[message.verification] : message.verification; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this ExtensionRangeOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ExtensionRangeOptions + * @instance + * @returns {Object.} JSON object + */ + ExtensionRangeOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ExtensionRangeOptions + * @function getTypeUrl + * @memberof google.protobuf.ExtensionRangeOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ExtensionRangeOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ExtensionRangeOptions"; + }; + + ExtensionRangeOptions.Declaration = (function() { + + /** + * Properties of a Declaration. + * @memberof google.protobuf.ExtensionRangeOptions + * @interface IDeclaration + * @property {number|null} [number] Declaration number + * @property {string|null} [fullName] Declaration fullName + * @property {string|null} [type] Declaration type + * @property {boolean|null} [reserved] Declaration reserved + * @property {boolean|null} [repeated] Declaration repeated + */ + + /** + * Constructs a new Declaration. + * @memberof google.protobuf.ExtensionRangeOptions + * @classdesc Represents a Declaration. + * @implements IDeclaration + * @constructor + * @param {google.protobuf.ExtensionRangeOptions.IDeclaration=} [properties] Properties to set + */ + function Declaration(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Declaration number. + * @member {number} number + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @instance + */ + Declaration.prototype.number = 0; + + /** + * Declaration fullName. + * @member {string} fullName + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @instance + */ + Declaration.prototype.fullName = ""; + + /** + * Declaration type. + * @member {string} type + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @instance + */ + Declaration.prototype.type = ""; + + /** + * Declaration reserved. + * @member {boolean} reserved + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @instance + */ + Declaration.prototype.reserved = false; + + /** + * Declaration repeated. + * @member {boolean} repeated + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @instance + */ + Declaration.prototype.repeated = false; + + /** + * Creates a new Declaration instance using the specified properties. + * @function create + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {google.protobuf.ExtensionRangeOptions.IDeclaration=} [properties] Properties to set + * @returns {google.protobuf.ExtensionRangeOptions.Declaration} Declaration instance + */ + Declaration.create = function create(properties) { + return new Declaration(properties); + }; + + /** + * Encodes the specified Declaration message. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.Declaration.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {google.protobuf.ExtensionRangeOptions.IDeclaration} message Declaration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Declaration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.number != null && Object.hasOwnProperty.call(message, "number")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.number); + if (message.fullName != null && Object.hasOwnProperty.call(message, "fullName")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.fullName); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.type); + if (message.reserved != null && Object.hasOwnProperty.call(message, "reserved")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.reserved); + if (message.repeated != null && Object.hasOwnProperty.call(message, "repeated")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.repeated); + return writer; + }; + + /** + * Encodes the specified Declaration message, length delimited. Does not implicitly {@link google.protobuf.ExtensionRangeOptions.Declaration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {google.protobuf.ExtensionRangeOptions.IDeclaration} message Declaration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Declaration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Declaration message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ExtensionRangeOptions.Declaration} Declaration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Declaration.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ExtensionRangeOptions.Declaration(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.number = reader.int32(); + break; + } + case 2: { + message.fullName = reader.string(); + break; + } + case 3: { + message.type = reader.string(); + break; + } + case 5: { + message.reserved = reader.bool(); + break; + } + case 6: { + message.repeated = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Declaration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ExtensionRangeOptions.Declaration} Declaration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Declaration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Declaration message. + * @function verify + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Declaration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.number != null && message.hasOwnProperty("number")) + if (!$util.isInteger(message.number)) + return "number: integer expected"; + if (message.fullName != null && message.hasOwnProperty("fullName")) + if (!$util.isString(message.fullName)) + return "fullName: string expected"; + if (message.type != null && message.hasOwnProperty("type")) + if (!$util.isString(message.type)) + return "type: string expected"; + if (message.reserved != null && message.hasOwnProperty("reserved")) + if (typeof message.reserved !== "boolean") + return "reserved: boolean expected"; + if (message.repeated != null && message.hasOwnProperty("repeated")) + if (typeof message.repeated !== "boolean") + return "repeated: boolean expected"; + return null; + }; + + /** + * Creates a Declaration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ExtensionRangeOptions.Declaration} Declaration + */ + Declaration.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ExtensionRangeOptions.Declaration) + return object; + var message = new $root.google.protobuf.ExtensionRangeOptions.Declaration(); + if (object.number != null) + message.number = object.number | 0; + if (object.fullName != null) + message.fullName = String(object.fullName); + if (object.type != null) + message.type = String(object.type); + if (object.reserved != null) + message.reserved = Boolean(object.reserved); + if (object.repeated != null) + message.repeated = Boolean(object.repeated); + return message; + }; + + /** + * Creates a plain object from a Declaration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {google.protobuf.ExtensionRangeOptions.Declaration} message Declaration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Declaration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.number = 0; + object.fullName = ""; + object.type = ""; + object.reserved = false; + object.repeated = false; + } + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.fullName != null && message.hasOwnProperty("fullName")) + object.fullName = message.fullName; + if (message.type != null && message.hasOwnProperty("type")) + object.type = message.type; + if (message.reserved != null && message.hasOwnProperty("reserved")) + object.reserved = message.reserved; + if (message.repeated != null && message.hasOwnProperty("repeated")) + object.repeated = message.repeated; + return object; + }; + + /** + * Converts this Declaration to JSON. + * @function toJSON + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @instance + * @returns {Object.} JSON object + */ + Declaration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Declaration + * @function getTypeUrl + * @memberof google.protobuf.ExtensionRangeOptions.Declaration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Declaration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ExtensionRangeOptions.Declaration"; + }; + + return Declaration; + })(); + + /** + * VerificationState enum. + * @name google.protobuf.ExtensionRangeOptions.VerificationState + * @enum {number} + * @property {number} DECLARATION=0 DECLARATION value + * @property {number} UNVERIFIED=1 UNVERIFIED value + */ + ExtensionRangeOptions.VerificationState = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DECLARATION"] = 0; + values[valuesById[1] = "UNVERIFIED"] = 1; + return values; + })(); + + return ExtensionRangeOptions; + })(); + + protobuf.FieldDescriptorProto = (function() { + + /** + * Properties of a FieldDescriptorProto. + * @memberof google.protobuf + * @interface IFieldDescriptorProto + * @property {string|null} [name] FieldDescriptorProto name + * @property {number|null} [number] FieldDescriptorProto number + * @property {google.protobuf.FieldDescriptorProto.Label|null} [label] FieldDescriptorProto label + * @property {google.protobuf.FieldDescriptorProto.Type|null} [type] FieldDescriptorProto type + * @property {string|null} [typeName] FieldDescriptorProto typeName + * @property {string|null} [extendee] FieldDescriptorProto extendee + * @property {string|null} [defaultValue] FieldDescriptorProto defaultValue + * @property {number|null} [oneofIndex] FieldDescriptorProto oneofIndex + * @property {string|null} [jsonName] FieldDescriptorProto jsonName + * @property {google.protobuf.IFieldOptions|null} [options] FieldDescriptorProto options + * @property {boolean|null} [proto3Optional] FieldDescriptorProto proto3Optional + */ + + /** + * Constructs a new FieldDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a FieldDescriptorProto. + * @implements IFieldDescriptorProto + * @constructor + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + */ + function FieldDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.name = ""; + + /** + * FieldDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.number = 0; + + /** + * FieldDescriptorProto label. + * @member {google.protobuf.FieldDescriptorProto.Label} label + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.label = 1; + + /** + * FieldDescriptorProto type. + * @member {google.protobuf.FieldDescriptorProto.Type} type + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.type = 1; + + /** + * FieldDescriptorProto typeName. + * @member {string} typeName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.typeName = ""; + + /** + * FieldDescriptorProto extendee. + * @member {string} extendee + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.extendee = ""; + + /** + * FieldDescriptorProto defaultValue. + * @member {string} defaultValue + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.defaultValue = ""; + + /** + * FieldDescriptorProto oneofIndex. + * @member {number} oneofIndex + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.oneofIndex = 0; + + /** + * FieldDescriptorProto jsonName. + * @member {string} jsonName + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.jsonName = ""; + + /** + * FieldDescriptorProto options. + * @member {google.protobuf.IFieldOptions|null|undefined} options + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.options = null; + + /** + * FieldDescriptorProto proto3Optional. + * @member {boolean} proto3Optional + * @memberof google.protobuf.FieldDescriptorProto + * @instance + */ + FieldDescriptorProto.prototype.proto3Optional = false; + + /** + * Creates a new FieldDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto instance + */ + FieldDescriptorProto.create = function create(properties) { + return new FieldDescriptorProto(properties); + }; + + /** + * Encodes the specified FieldDescriptorProto message. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.extendee != null && Object.hasOwnProperty.call(message, "extendee")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.extendee); + if (message.number != null && Object.hasOwnProperty.call(message, "number")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.number); + if (message.label != null && Object.hasOwnProperty.call(message, "label")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.label); + if (message.type != null && Object.hasOwnProperty.call(message, "type")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.type); + if (message.typeName != null && Object.hasOwnProperty.call(message, "typeName")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.typeName); + if (message.defaultValue != null && Object.hasOwnProperty.call(message, "defaultValue")) + writer.uint32(/* id 7, wireType 2 =*/58).string(message.defaultValue); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.FieldOptions.encode(message.options, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); + if (message.oneofIndex != null && Object.hasOwnProperty.call(message, "oneofIndex")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.oneofIndex); + if (message.jsonName != null && Object.hasOwnProperty.call(message, "jsonName")) + writer.uint32(/* id 10, wireType 2 =*/82).string(message.jsonName); + if (message.proto3Optional != null && Object.hasOwnProperty.call(message, "proto3Optional")) + writer.uint32(/* id 17, wireType 0 =*/136).bool(message.proto3Optional); + return writer; + }; + + /** + * Encodes the specified FieldDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.FieldDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.IFieldDescriptorProto} message FieldDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 3: { + message.number = reader.int32(); + break; + } + case 4: { + message.label = reader.int32(); + break; + } + case 5: { + message.type = reader.int32(); + break; + } + case 6: { + message.typeName = reader.string(); + break; + } + case 2: { + message.extendee = reader.string(); + break; + } + case 7: { + message.defaultValue = reader.string(); + break; + } + case 9: { + message.oneofIndex = reader.int32(); + break; + } + case 10: { + message.jsonName = reader.string(); + break; + } + case 8: { + message.options = $root.google.protobuf.FieldOptions.decode(reader, reader.uint32()); + break; + } + case 17: { + message.proto3Optional = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldDescriptorProto message. + * @function verify + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.number != null && message.hasOwnProperty("number")) + if (!$util.isInteger(message.number)) + return "number: integer expected"; + if (message.label != null && message.hasOwnProperty("label")) + switch (message.label) { + default: + return "label: enum value expected"; + case 1: + case 3: + case 2: + break; + } + if (message.type != null && message.hasOwnProperty("type")) + switch (message.type) { + default: + return "type: enum value expected"; + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + break; + } + if (message.typeName != null && message.hasOwnProperty("typeName")) + if (!$util.isString(message.typeName)) + return "typeName: string expected"; + if (message.extendee != null && message.hasOwnProperty("extendee")) + if (!$util.isString(message.extendee)) + return "extendee: string expected"; + if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + if (!$util.isString(message.defaultValue)) + return "defaultValue: string expected"; + if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + if (!$util.isInteger(message.oneofIndex)) + return "oneofIndex: integer expected"; + if (message.jsonName != null && message.hasOwnProperty("jsonName")) + if (!$util.isString(message.jsonName)) + return "jsonName: string expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.FieldOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional")) + if (typeof message.proto3Optional !== "boolean") + return "proto3Optional: boolean expected"; + return null; + }; + + /** + * Creates a FieldDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldDescriptorProto} FieldDescriptorProto + */ + FieldDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldDescriptorProto) + return object; + var message = new $root.google.protobuf.FieldDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + switch (object.label) { + default: + if (typeof object.label === "number") { + message.label = object.label; + break; + } + break; + case "LABEL_OPTIONAL": + case 1: + message.label = 1; + break; + case "LABEL_REPEATED": + case 3: + message.label = 3; + break; + case "LABEL_REQUIRED": + case 2: + message.label = 2; + break; + } + switch (object.type) { + default: + if (typeof object.type === "number") { + message.type = object.type; + break; + } + break; + case "TYPE_DOUBLE": + case 1: + message.type = 1; + break; + case "TYPE_FLOAT": + case 2: + message.type = 2; + break; + case "TYPE_INT64": + case 3: + message.type = 3; + break; + case "TYPE_UINT64": + case 4: + message.type = 4; + break; + case "TYPE_INT32": + case 5: + message.type = 5; + break; + case "TYPE_FIXED64": + case 6: + message.type = 6; + break; + case "TYPE_FIXED32": + case 7: + message.type = 7; + break; + case "TYPE_BOOL": + case 8: + message.type = 8; + break; + case "TYPE_STRING": + case 9: + message.type = 9; + break; + case "TYPE_GROUP": + case 10: + message.type = 10; + break; + case "TYPE_MESSAGE": + case 11: + message.type = 11; + break; + case "TYPE_BYTES": + case 12: + message.type = 12; + break; + case "TYPE_UINT32": + case 13: + message.type = 13; + break; + case "TYPE_ENUM": + case 14: + message.type = 14; + break; + case "TYPE_SFIXED32": + case 15: + message.type = 15; + break; + case "TYPE_SFIXED64": + case 16: + message.type = 16; + break; + case "TYPE_SINT32": + case 17: + message.type = 17; + break; + case "TYPE_SINT64": + case 18: + message.type = 18; + break; + } + if (object.typeName != null) + message.typeName = String(object.typeName); + if (object.extendee != null) + message.extendee = String(object.extendee); + if (object.defaultValue != null) + message.defaultValue = String(object.defaultValue); + if (object.oneofIndex != null) + message.oneofIndex = object.oneofIndex | 0; + if (object.jsonName != null) + message.jsonName = String(object.jsonName); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.FieldDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.FieldOptions.fromObject(object.options); + } + if (object.proto3Optional != null) + message.proto3Optional = Boolean(object.proto3Optional); + return message; + }; + + /** + * Creates a plain object from a FieldDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {google.protobuf.FieldDescriptorProto} message FieldDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.extendee = ""; + object.number = 0; + object.label = options.enums === String ? "LABEL_OPTIONAL" : 1; + object.type = options.enums === String ? "TYPE_DOUBLE" : 1; + object.typeName = ""; + object.defaultValue = ""; + object.options = null; + object.oneofIndex = 0; + object.jsonName = ""; + object.proto3Optional = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.extendee != null && message.hasOwnProperty("extendee")) + object.extendee = message.extendee; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.label != null && message.hasOwnProperty("label")) + object.label = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Label[message.label] === undefined ? message.label : $root.google.protobuf.FieldDescriptorProto.Label[message.label] : message.label; + if (message.type != null && message.hasOwnProperty("type")) + object.type = options.enums === String ? $root.google.protobuf.FieldDescriptorProto.Type[message.type] === undefined ? message.type : $root.google.protobuf.FieldDescriptorProto.Type[message.type] : message.type; + if (message.typeName != null && message.hasOwnProperty("typeName")) + object.typeName = message.typeName; + if (message.defaultValue != null && message.hasOwnProperty("defaultValue")) + object.defaultValue = message.defaultValue; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.FieldOptions.toObject(message.options, options); + if (message.oneofIndex != null && message.hasOwnProperty("oneofIndex")) + object.oneofIndex = message.oneofIndex; + if (message.jsonName != null && message.hasOwnProperty("jsonName")) + object.jsonName = message.jsonName; + if (message.proto3Optional != null && message.hasOwnProperty("proto3Optional")) + object.proto3Optional = message.proto3Optional; + return object; + }; + + /** + * Converts this FieldDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.FieldDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + FieldDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FieldDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.FieldDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FieldDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldDescriptorProto"; + }; + + /** + * Type enum. + * @name google.protobuf.FieldDescriptorProto.Type + * @enum {number} + * @property {number} TYPE_DOUBLE=1 TYPE_DOUBLE value + * @property {number} TYPE_FLOAT=2 TYPE_FLOAT value + * @property {number} TYPE_INT64=3 TYPE_INT64 value + * @property {number} TYPE_UINT64=4 TYPE_UINT64 value + * @property {number} TYPE_INT32=5 TYPE_INT32 value + * @property {number} TYPE_FIXED64=6 TYPE_FIXED64 value + * @property {number} TYPE_FIXED32=7 TYPE_FIXED32 value + * @property {number} TYPE_BOOL=8 TYPE_BOOL value + * @property {number} TYPE_STRING=9 TYPE_STRING value + * @property {number} TYPE_GROUP=10 TYPE_GROUP value + * @property {number} TYPE_MESSAGE=11 TYPE_MESSAGE value + * @property {number} TYPE_BYTES=12 TYPE_BYTES value + * @property {number} TYPE_UINT32=13 TYPE_UINT32 value + * @property {number} TYPE_ENUM=14 TYPE_ENUM value + * @property {number} TYPE_SFIXED32=15 TYPE_SFIXED32 value + * @property {number} TYPE_SFIXED64=16 TYPE_SFIXED64 value + * @property {number} TYPE_SINT32=17 TYPE_SINT32 value + * @property {number} TYPE_SINT64=18 TYPE_SINT64 value + */ + FieldDescriptorProto.Type = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "TYPE_DOUBLE"] = 1; + values[valuesById[2] = "TYPE_FLOAT"] = 2; + values[valuesById[3] = "TYPE_INT64"] = 3; + values[valuesById[4] = "TYPE_UINT64"] = 4; + values[valuesById[5] = "TYPE_INT32"] = 5; + values[valuesById[6] = "TYPE_FIXED64"] = 6; + values[valuesById[7] = "TYPE_FIXED32"] = 7; + values[valuesById[8] = "TYPE_BOOL"] = 8; + values[valuesById[9] = "TYPE_STRING"] = 9; + values[valuesById[10] = "TYPE_GROUP"] = 10; + values[valuesById[11] = "TYPE_MESSAGE"] = 11; + values[valuesById[12] = "TYPE_BYTES"] = 12; + values[valuesById[13] = "TYPE_UINT32"] = 13; + values[valuesById[14] = "TYPE_ENUM"] = 14; + values[valuesById[15] = "TYPE_SFIXED32"] = 15; + values[valuesById[16] = "TYPE_SFIXED64"] = 16; + values[valuesById[17] = "TYPE_SINT32"] = 17; + values[valuesById[18] = "TYPE_SINT64"] = 18; + return values; + })(); + + /** + * Label enum. + * @name google.protobuf.FieldDescriptorProto.Label + * @enum {number} + * @property {number} LABEL_OPTIONAL=1 LABEL_OPTIONAL value + * @property {number} LABEL_REPEATED=3 LABEL_REPEATED value + * @property {number} LABEL_REQUIRED=2 LABEL_REQUIRED value + */ + FieldDescriptorProto.Label = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "LABEL_OPTIONAL"] = 1; + values[valuesById[3] = "LABEL_REPEATED"] = 3; + values[valuesById[2] = "LABEL_REQUIRED"] = 2; + return values; + })(); + + return FieldDescriptorProto; + })(); + + protobuf.OneofDescriptorProto = (function() { + + /** + * Properties of an OneofDescriptorProto. + * @memberof google.protobuf + * @interface IOneofDescriptorProto + * @property {string|null} [name] OneofDescriptorProto name + * @property {google.protobuf.IOneofOptions|null} [options] OneofDescriptorProto options + */ + + /** + * Constructs a new OneofDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an OneofDescriptorProto. + * @implements IOneofDescriptorProto + * @constructor + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + */ + function OneofDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.name = ""; + + /** + * OneofDescriptorProto options. + * @member {google.protobuf.IOneofOptions|null|undefined} options + * @memberof google.protobuf.OneofDescriptorProto + * @instance + */ + OneofDescriptorProto.prototype.options = null; + + /** + * Creates a new OneofDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto instance + */ + OneofDescriptorProto.create = function create(properties) { + return new OneofDescriptorProto(properties); + }; + + /** + * Encodes the specified OneofDescriptorProto message. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.OneofOptions.encode(message.options, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OneofDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.OneofDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.IOneofDescriptorProto} message OneofDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.OneofDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.options = $root.google.protobuf.OneofOptions.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OneofDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OneofDescriptorProto message. + * @function verify + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.OneofOptions.verify(message.options); + if (error) + return "options." + error; + } + return null; + }; + + /** + * Creates an OneofDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofDescriptorProto} OneofDescriptorProto + */ + OneofDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofDescriptorProto) + return object; + var message = new $root.google.protobuf.OneofDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.OneofDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.OneofOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an OneofDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {google.protobuf.OneofDescriptorProto} message OneofDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.OneofOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this OneofDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.OneofDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + OneofDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OneofDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.OneofDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OneofDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.OneofDescriptorProto"; + }; + + return OneofDescriptorProto; + })(); + + protobuf.EnumDescriptorProto = (function() { + + /** + * Properties of an EnumDescriptorProto. + * @memberof google.protobuf + * @interface IEnumDescriptorProto + * @property {string|null} [name] EnumDescriptorProto name + * @property {Array.|null} [value] EnumDescriptorProto value + * @property {google.protobuf.IEnumOptions|null} [options] EnumDescriptorProto options + * @property {Array.|null} [reservedRange] EnumDescriptorProto reservedRange + * @property {Array.|null} [reservedName] EnumDescriptorProto reservedName + * @property {google.protobuf.SymbolVisibility|null} [visibility] EnumDescriptorProto visibility + */ + + /** + * Constructs a new EnumDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumDescriptorProto. + * @implements IEnumDescriptorProto + * @constructor + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + */ + function EnumDescriptorProto(properties) { + this.value = []; + this.reservedRange = []; + this.reservedName = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.name = ""; + + /** + * EnumDescriptorProto value. + * @member {Array.} value + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.value = $util.emptyArray; + + /** + * EnumDescriptorProto options. + * @member {google.protobuf.IEnumOptions|null|undefined} options + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.options = null; + + /** + * EnumDescriptorProto reservedRange. + * @member {Array.} reservedRange + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedRange = $util.emptyArray; + + /** + * EnumDescriptorProto reservedName. + * @member {Array.} reservedName + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.reservedName = $util.emptyArray; + + /** + * EnumDescriptorProto visibility. + * @member {google.protobuf.SymbolVisibility} visibility + * @memberof google.protobuf.EnumDescriptorProto + * @instance + */ + EnumDescriptorProto.prototype.visibility = 0; + + /** + * Creates a new EnumDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto instance + */ + EnumDescriptorProto.create = function create(properties) { + return new EnumDescriptorProto(properties); + }; + + /** + * Encodes the specified EnumDescriptorProto message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.value != null && message.value.length) + for (var i = 0; i < message.value.length; ++i) + $root.google.protobuf.EnumValueDescriptorProto.encode(message.value[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.EnumOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.reservedRange != null && message.reservedRange.length) + for (var i = 0; i < message.reservedRange.length; ++i) + $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.encode(message.reservedRange[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.reservedName != null && message.reservedName.length) + for (var i = 0; i < message.reservedName.length; ++i) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.reservedName[i]); + if (message.visibility != null && Object.hasOwnProperty.call(message, "visibility")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.visibility); + return writer; + }; + + /** + * Encodes the specified EnumDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.IEnumDescriptorProto} message EnumDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (!(message.value && message.value.length)) + message.value = []; + message.value.push($root.google.protobuf.EnumValueDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 3: { + message.options = $root.google.protobuf.EnumOptions.decode(reader, reader.uint32()); + break; + } + case 4: { + if (!(message.reservedRange && message.reservedRange.length)) + message.reservedRange = []; + message.reservedRange.push($root.google.protobuf.EnumDescriptorProto.EnumReservedRange.decode(reader, reader.uint32())); + break; + } + case 5: { + if (!(message.reservedName && message.reservedName.length)) + message.reservedName = []; + message.reservedName.push(reader.string()); + break; + } + case 6: { + message.visibility = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.value != null && message.hasOwnProperty("value")) { + if (!Array.isArray(message.value)) + return "value: array expected"; + for (var i = 0; i < message.value.length; ++i) { + var error = $root.google.protobuf.EnumValueDescriptorProto.verify(message.value[i]); + if (error) + return "value." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.EnumOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.reservedRange != null && message.hasOwnProperty("reservedRange")) { + if (!Array.isArray(message.reservedRange)) + return "reservedRange: array expected"; + for (var i = 0; i < message.reservedRange.length; ++i) { + var error = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.verify(message.reservedRange[i]); + if (error) + return "reservedRange." + error; + } + } + if (message.reservedName != null && message.hasOwnProperty("reservedName")) { + if (!Array.isArray(message.reservedName)) + return "reservedName: array expected"; + for (var i = 0; i < message.reservedName.length; ++i) + if (!$util.isString(message.reservedName[i])) + return "reservedName: string[] expected"; + } + if (message.visibility != null && message.hasOwnProperty("visibility")) + switch (message.visibility) { + default: + return "visibility: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates an EnumDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto} EnumDescriptorProto + */ + EnumDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.value) { + if (!Array.isArray(object.value)) + throw TypeError(".google.protobuf.EnumDescriptorProto.value: array expected"); + message.value = []; + for (var i = 0; i < object.value.length; ++i) { + if (typeof object.value[i] !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.value: object expected"); + message.value[i] = $root.google.protobuf.EnumValueDescriptorProto.fromObject(object.value[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumOptions.fromObject(object.options); + } + if (object.reservedRange) { + if (!Array.isArray(object.reservedRange)) + throw TypeError(".google.protobuf.EnumDescriptorProto.reservedRange: array expected"); + message.reservedRange = []; + for (var i = 0; i < object.reservedRange.length; ++i) { + if (typeof object.reservedRange[i] !== "object") + throw TypeError(".google.protobuf.EnumDescriptorProto.reservedRange: object expected"); + message.reservedRange[i] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.fromObject(object.reservedRange[i]); + } + } + if (object.reservedName) { + if (!Array.isArray(object.reservedName)) + throw TypeError(".google.protobuf.EnumDescriptorProto.reservedName: array expected"); + message.reservedName = []; + for (var i = 0; i < object.reservedName.length; ++i) + message.reservedName[i] = String(object.reservedName[i]); + } + switch (object.visibility) { + default: + if (typeof object.visibility === "number") { + message.visibility = object.visibility; + break; + } + break; + case "VISIBILITY_UNSET": + case 0: + message.visibility = 0; + break; + case "VISIBILITY_LOCAL": + case 1: + message.visibility = 1; + break; + case "VISIBILITY_EXPORT": + case 2: + message.visibility = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an EnumDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {google.protobuf.EnumDescriptorProto} message EnumDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.value = []; + object.reservedRange = []; + object.reservedName = []; + } + if (options.defaults) { + object.name = ""; + object.options = null; + object.visibility = options.enums === String ? "VISIBILITY_UNSET" : 0; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.value && message.value.length) { + object.value = []; + for (var j = 0; j < message.value.length; ++j) + object.value[j] = $root.google.protobuf.EnumValueDescriptorProto.toObject(message.value[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumOptions.toObject(message.options, options); + if (message.reservedRange && message.reservedRange.length) { + object.reservedRange = []; + for (var j = 0; j < message.reservedRange.length; ++j) + object.reservedRange[j] = $root.google.protobuf.EnumDescriptorProto.EnumReservedRange.toObject(message.reservedRange[j], options); + } + if (message.reservedName && message.reservedName.length) { + object.reservedName = []; + for (var j = 0; j < message.reservedName.length; ++j) + object.reservedName[j] = message.reservedName[j]; + } + if (message.visibility != null && message.hasOwnProperty("visibility")) + object.visibility = options.enums === String ? $root.google.protobuf.SymbolVisibility[message.visibility] === undefined ? message.visibility : $root.google.protobuf.SymbolVisibility[message.visibility] : message.visibility; + return object; + }; + + /** + * Converts this EnumDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EnumDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.EnumDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumDescriptorProto"; + }; + + EnumDescriptorProto.EnumReservedRange = (function() { + + /** + * Properties of an EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @interface IEnumReservedRange + * @property {number|null} [start] EnumReservedRange start + * @property {number|null} [end] EnumReservedRange end + */ + + /** + * Constructs a new EnumReservedRange. + * @memberof google.protobuf.EnumDescriptorProto + * @classdesc Represents an EnumReservedRange. + * @implements IEnumReservedRange + * @constructor + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + */ + function EnumReservedRange(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumReservedRange start. + * @member {number} start + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.start = 0; + + /** + * EnumReservedRange end. + * @member {number} end + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + */ + EnumReservedRange.prototype.end = 0; + + /** + * Creates a new EnumReservedRange instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange=} [properties] Properties to set + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange instance + */ + EnumReservedRange.create = function create(properties) { + return new EnumReservedRange(properties); + }; + + /** + * Encodes the specified EnumReservedRange message. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.start != null && Object.hasOwnProperty.call(message, "start")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.start); + if (message.end != null && Object.hasOwnProperty.call(message, "end")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.end); + return writer; + }; + + /** + * Encodes the specified EnumReservedRange message, length delimited. Does not implicitly {@link google.protobuf.EnumDescriptorProto.EnumReservedRange.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.IEnumReservedRange} message EnumReservedRange message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumReservedRange.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.start = reader.int32(); + break; + } + case 2: { + message.end = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumReservedRange message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumReservedRange.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumReservedRange message. + * @function verify + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumReservedRange.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.start != null && message.hasOwnProperty("start")) + if (!$util.isInteger(message.start)) + return "start: integer expected"; + if (message.end != null && message.hasOwnProperty("end")) + if (!$util.isInteger(message.end)) + return "end: integer expected"; + return null; + }; + + /** + * Creates an EnumReservedRange message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumDescriptorProto.EnumReservedRange} EnumReservedRange + */ + EnumReservedRange.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumDescriptorProto.EnumReservedRange) + return object; + var message = new $root.google.protobuf.EnumDescriptorProto.EnumReservedRange(); + if (object.start != null) + message.start = object.start | 0; + if (object.end != null) + message.end = object.end | 0; + return message; + }; + + /** + * Creates a plain object from an EnumReservedRange message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {google.protobuf.EnumDescriptorProto.EnumReservedRange} message EnumReservedRange + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumReservedRange.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.start = 0; + object.end = 0; + } + if (message.start != null && message.hasOwnProperty("start")) + object.start = message.start; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + return object; + }; + + /** + * Converts this EnumReservedRange to JSON. + * @function toJSON + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @instance + * @returns {Object.} JSON object + */ + EnumReservedRange.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EnumReservedRange + * @function getTypeUrl + * @memberof google.protobuf.EnumDescriptorProto.EnumReservedRange + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumReservedRange.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumDescriptorProto.EnumReservedRange"; + }; + + return EnumReservedRange; + })(); + + return EnumDescriptorProto; + })(); + + protobuf.EnumValueDescriptorProto = (function() { + + /** + * Properties of an EnumValueDescriptorProto. + * @memberof google.protobuf + * @interface IEnumValueDescriptorProto + * @property {string|null} [name] EnumValueDescriptorProto name + * @property {number|null} [number] EnumValueDescriptorProto number + * @property {google.protobuf.IEnumValueOptions|null} [options] EnumValueDescriptorProto options + */ + + /** + * Constructs a new EnumValueDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents an EnumValueDescriptorProto. + * @implements IEnumValueDescriptorProto + * @constructor + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + */ + function EnumValueDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.name = ""; + + /** + * EnumValueDescriptorProto number. + * @member {number} number + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.number = 0; + + /** + * EnumValueDescriptorProto options. + * @member {google.protobuf.IEnumValueOptions|null|undefined} options + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + */ + EnumValueDescriptorProto.prototype.options = null; + + /** + * Creates a new EnumValueDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto instance + */ + EnumValueDescriptorProto.create = function create(properties) { + return new EnumValueDescriptorProto(properties); + }; + + /** + * Encodes the specified EnumValueDescriptorProto message. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.number != null && Object.hasOwnProperty.call(message, "number")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.number); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.EnumValueOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EnumValueDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.EnumValueDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.IEnumValueDescriptorProto} message EnumValueDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumValueDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.number = reader.int32(); + break; + } + case 3: { + message.options = $root.google.protobuf.EnumValueOptions.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumValueDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumValueDescriptorProto message. + * @function verify + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.number != null && message.hasOwnProperty("number")) + if (!$util.isInteger(message.number)) + return "number: integer expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.EnumValueOptions.verify(message.options); + if (error) + return "options." + error; + } + return null; + }; + + /** + * Creates an EnumValueDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueDescriptorProto} EnumValueDescriptorProto + */ + EnumValueDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueDescriptorProto) + return object; + var message = new $root.google.protobuf.EnumValueDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.number != null) + message.number = object.number | 0; + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.EnumValueDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.EnumValueOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from an EnumValueDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {google.protobuf.EnumValueDescriptorProto} message EnumValueDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.number = 0; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.number != null && message.hasOwnProperty("number")) + object.number = message.number; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.EnumValueOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this EnumValueDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + EnumValueDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EnumValueDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.EnumValueDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumValueDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumValueDescriptorProto"; + }; + + return EnumValueDescriptorProto; + })(); + + protobuf.ServiceDescriptorProto = (function() { + + /** + * Properties of a ServiceDescriptorProto. + * @memberof google.protobuf + * @interface IServiceDescriptorProto + * @property {string|null} [name] ServiceDescriptorProto name + * @property {Array.|null} [method] ServiceDescriptorProto method + * @property {google.protobuf.IServiceOptions|null} [options] ServiceDescriptorProto options + */ + + /** + * Constructs a new ServiceDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a ServiceDescriptorProto. + * @implements IServiceDescriptorProto + * @constructor + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + */ + function ServiceDescriptorProto(properties) { + this.method = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.name = ""; + + /** + * ServiceDescriptorProto method. + * @member {Array.} method + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.method = $util.emptyArray; + + /** + * ServiceDescriptorProto options. + * @member {google.protobuf.IServiceOptions|null|undefined} options + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + */ + ServiceDescriptorProto.prototype.options = null; + + /** + * Creates a new ServiceDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto instance + */ + ServiceDescriptorProto.create = function create(properties) { + return new ServiceDescriptorProto(properties); + }; + + /** + * Encodes the specified ServiceDescriptorProto message. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.method != null && message.method.length) + for (var i = 0; i < message.method.length; ++i) + $root.google.protobuf.MethodDescriptorProto.encode(message.method[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.ServiceOptions.encode(message.options, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ServiceDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.ServiceDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.IServiceDescriptorProto} message ServiceDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ServiceDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + if (!(message.method && message.method.length)) + message.method = []; + message.method.push($root.google.protobuf.MethodDescriptorProto.decode(reader, reader.uint32())); + break; + } + case 3: { + message.options = $root.google.protobuf.ServiceOptions.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServiceDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServiceDescriptorProto message. + * @function verify + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.method != null && message.hasOwnProperty("method")) { + if (!Array.isArray(message.method)) + return "method: array expected"; + for (var i = 0; i < message.method.length; ++i) { + var error = $root.google.protobuf.MethodDescriptorProto.verify(message.method[i]); + if (error) + return "method." + error; + } + } + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.ServiceOptions.verify(message.options); + if (error) + return "options." + error; + } + return null; + }; + + /** + * Creates a ServiceDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceDescriptorProto} ServiceDescriptorProto + */ + ServiceDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceDescriptorProto) + return object; + var message = new $root.google.protobuf.ServiceDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.method) { + if (!Array.isArray(object.method)) + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: array expected"); + message.method = []; + for (var i = 0; i < object.method.length; ++i) { + if (typeof object.method[i] !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.method: object expected"); + message.method[i] = $root.google.protobuf.MethodDescriptorProto.fromObject(object.method[i]); + } + } + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.ServiceDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.ServiceOptions.fromObject(object.options); + } + return message; + }; + + /** + * Creates a plain object from a ServiceDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {google.protobuf.ServiceDescriptorProto} message ServiceDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.method = []; + if (options.defaults) { + object.name = ""; + object.options = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.method && message.method.length) { + object.method = []; + for (var j = 0; j < message.method.length; ++j) + object.method[j] = $root.google.protobuf.MethodDescriptorProto.toObject(message.method[j], options); + } + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.ServiceOptions.toObject(message.options, options); + return object; + }; + + /** + * Converts this ServiceDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + ServiceDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ServiceDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.ServiceDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServiceDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ServiceDescriptorProto"; + }; + + return ServiceDescriptorProto; + })(); + + protobuf.MethodDescriptorProto = (function() { + + /** + * Properties of a MethodDescriptorProto. + * @memberof google.protobuf + * @interface IMethodDescriptorProto + * @property {string|null} [name] MethodDescriptorProto name + * @property {string|null} [inputType] MethodDescriptorProto inputType + * @property {string|null} [outputType] MethodDescriptorProto outputType + * @property {google.protobuf.IMethodOptions|null} [options] MethodDescriptorProto options + * @property {boolean|null} [clientStreaming] MethodDescriptorProto clientStreaming + * @property {boolean|null} [serverStreaming] MethodDescriptorProto serverStreaming + */ + + /** + * Constructs a new MethodDescriptorProto. + * @memberof google.protobuf + * @classdesc Represents a MethodDescriptorProto. + * @implements IMethodDescriptorProto + * @constructor + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + */ + function MethodDescriptorProto(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodDescriptorProto name. + * @member {string} name + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.name = ""; + + /** + * MethodDescriptorProto inputType. + * @member {string} inputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.inputType = ""; + + /** + * MethodDescriptorProto outputType. + * @member {string} outputType + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.outputType = ""; + + /** + * MethodDescriptorProto options. + * @member {google.protobuf.IMethodOptions|null|undefined} options + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.options = null; + + /** + * MethodDescriptorProto clientStreaming. + * @member {boolean} clientStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.clientStreaming = false; + + /** + * MethodDescriptorProto serverStreaming. + * @member {boolean} serverStreaming + * @memberof google.protobuf.MethodDescriptorProto + * @instance + */ + MethodDescriptorProto.prototype.serverStreaming = false; + + /** + * Creates a new MethodDescriptorProto instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto=} [properties] Properties to set + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto instance + */ + MethodDescriptorProto.create = function create(properties) { + return new MethodDescriptorProto(properties); + }; + + /** + * Encodes the specified MethodDescriptorProto message. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.inputType != null && Object.hasOwnProperty.call(message, "inputType")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.inputType); + if (message.outputType != null && Object.hasOwnProperty.call(message, "outputType")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.outputType); + if (message.options != null && Object.hasOwnProperty.call(message, "options")) + $root.google.protobuf.MethodOptions.encode(message.options, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.clientStreaming != null && Object.hasOwnProperty.call(message, "clientStreaming")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.clientStreaming); + if (message.serverStreaming != null && Object.hasOwnProperty.call(message, "serverStreaming")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.serverStreaming); + return writer; + }; + + /** + * Encodes the specified MethodDescriptorProto message, length delimited. Does not implicitly {@link google.protobuf.MethodDescriptorProto.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.IMethodDescriptorProto} message MethodDescriptorProto message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodDescriptorProto.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.MethodDescriptorProto(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.inputType = reader.string(); + break; + } + case 3: { + message.outputType = reader.string(); + break; + } + case 4: { + message.options = $root.google.protobuf.MethodOptions.decode(reader, reader.uint32()); + break; + } + case 5: { + message.clientStreaming = reader.bool(); + break; + } + case 6: { + message.serverStreaming = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MethodDescriptorProto message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodDescriptorProto.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MethodDescriptorProto message. + * @function verify + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodDescriptorProto.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.inputType != null && message.hasOwnProperty("inputType")) + if (!$util.isString(message.inputType)) + return "inputType: string expected"; + if (message.outputType != null && message.hasOwnProperty("outputType")) + if (!$util.isString(message.outputType)) + return "outputType: string expected"; + if (message.options != null && message.hasOwnProperty("options")) { + var error = $root.google.protobuf.MethodOptions.verify(message.options); + if (error) + return "options." + error; + } + if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + if (typeof message.clientStreaming !== "boolean") + return "clientStreaming: boolean expected"; + if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + if (typeof message.serverStreaming !== "boolean") + return "serverStreaming: boolean expected"; + return null; + }; + + /** + * Creates a MethodDescriptorProto message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodDescriptorProto} MethodDescriptorProto + */ + MethodDescriptorProto.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodDescriptorProto) + return object; + var message = new $root.google.protobuf.MethodDescriptorProto(); + if (object.name != null) + message.name = String(object.name); + if (object.inputType != null) + message.inputType = String(object.inputType); + if (object.outputType != null) + message.outputType = String(object.outputType); + if (object.options != null) { + if (typeof object.options !== "object") + throw TypeError(".google.protobuf.MethodDescriptorProto.options: object expected"); + message.options = $root.google.protobuf.MethodOptions.fromObject(object.options); + } + if (object.clientStreaming != null) + message.clientStreaming = Boolean(object.clientStreaming); + if (object.serverStreaming != null) + message.serverStreaming = Boolean(object.serverStreaming); + return message; + }; + + /** + * Creates a plain object from a MethodDescriptorProto message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {google.protobuf.MethodDescriptorProto} message MethodDescriptorProto + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodDescriptorProto.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.inputType = ""; + object.outputType = ""; + object.options = null; + object.clientStreaming = false; + object.serverStreaming = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.inputType != null && message.hasOwnProperty("inputType")) + object.inputType = message.inputType; + if (message.outputType != null && message.hasOwnProperty("outputType")) + object.outputType = message.outputType; + if (message.options != null && message.hasOwnProperty("options")) + object.options = $root.google.protobuf.MethodOptions.toObject(message.options, options); + if (message.clientStreaming != null && message.hasOwnProperty("clientStreaming")) + object.clientStreaming = message.clientStreaming; + if (message.serverStreaming != null && message.hasOwnProperty("serverStreaming")) + object.serverStreaming = message.serverStreaming; + return object; + }; + + /** + * Converts this MethodDescriptorProto to JSON. + * @function toJSON + * @memberof google.protobuf.MethodDescriptorProto + * @instance + * @returns {Object.} JSON object + */ + MethodDescriptorProto.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MethodDescriptorProto + * @function getTypeUrl + * @memberof google.protobuf.MethodDescriptorProto + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MethodDescriptorProto.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MethodDescriptorProto"; + }; + + return MethodDescriptorProto; + })(); + + protobuf.FileOptions = (function() { + + /** + * Properties of a FileOptions. + * @memberof google.protobuf + * @interface IFileOptions + * @property {string|null} [javaPackage] FileOptions javaPackage + * @property {string|null} [javaOuterClassname] FileOptions javaOuterClassname + * @property {boolean|null} [javaMultipleFiles] FileOptions javaMultipleFiles + * @property {boolean|null} [javaGenerateEqualsAndHash] FileOptions javaGenerateEqualsAndHash + * @property {boolean|null} [javaStringCheckUtf8] FileOptions javaStringCheckUtf8 + * @property {google.protobuf.FileOptions.OptimizeMode|null} [optimizeFor] FileOptions optimizeFor + * @property {string|null} [goPackage] FileOptions goPackage + * @property {boolean|null} [ccGenericServices] FileOptions ccGenericServices + * @property {boolean|null} [javaGenericServices] FileOptions javaGenericServices + * @property {boolean|null} [pyGenericServices] FileOptions pyGenericServices + * @property {boolean|null} [deprecated] FileOptions deprecated + * @property {boolean|null} [ccEnableArenas] FileOptions ccEnableArenas + * @property {string|null} [objcClassPrefix] FileOptions objcClassPrefix + * @property {string|null} [csharpNamespace] FileOptions csharpNamespace + * @property {string|null} [swiftPrefix] FileOptions swiftPrefix + * @property {string|null} [phpClassPrefix] FileOptions phpClassPrefix + * @property {string|null} [phpNamespace] FileOptions phpNamespace + * @property {string|null} [phpMetadataNamespace] FileOptions phpMetadataNamespace + * @property {string|null} [rubyPackage] FileOptions rubyPackage + * @property {google.protobuf.IFeatureSet|null} [features] FileOptions features + * @property {Array.|null} [uninterpretedOption] FileOptions uninterpretedOption + */ + + /** + * Constructs a new FileOptions. + * @memberof google.protobuf + * @classdesc Represents a FileOptions. + * @implements IFileOptions + * @constructor + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + */ + function FileOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FileOptions javaPackage. + * @member {string} javaPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaPackage = ""; + + /** + * FileOptions javaOuterClassname. + * @member {string} javaOuterClassname + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaOuterClassname = ""; + + /** + * FileOptions javaMultipleFiles. + * @member {boolean} javaMultipleFiles + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaMultipleFiles = false; + + /** + * FileOptions javaGenerateEqualsAndHash. + * @member {boolean} javaGenerateEqualsAndHash + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenerateEqualsAndHash = false; + + /** + * FileOptions javaStringCheckUtf8. + * @member {boolean} javaStringCheckUtf8 + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaStringCheckUtf8 = false; + + /** + * FileOptions optimizeFor. + * @member {google.protobuf.FileOptions.OptimizeMode} optimizeFor + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.optimizeFor = 1; + + /** + * FileOptions goPackage. + * @member {string} goPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.goPackage = ""; + + /** + * FileOptions ccGenericServices. + * @member {boolean} ccGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccGenericServices = false; + + /** + * FileOptions javaGenericServices. + * @member {boolean} javaGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.javaGenericServices = false; + + /** + * FileOptions pyGenericServices. + * @member {boolean} pyGenericServices + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.pyGenericServices = false; + + /** + * FileOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.deprecated = false; + + /** + * FileOptions ccEnableArenas. + * @member {boolean} ccEnableArenas + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.ccEnableArenas = true; + + /** + * FileOptions objcClassPrefix. + * @member {string} objcClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.objcClassPrefix = ""; + + /** + * FileOptions csharpNamespace. + * @member {string} csharpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.csharpNamespace = ""; + + /** + * FileOptions swiftPrefix. + * @member {string} swiftPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.swiftPrefix = ""; + + /** + * FileOptions phpClassPrefix. + * @member {string} phpClassPrefix + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpClassPrefix = ""; + + /** + * FileOptions phpNamespace. + * @member {string} phpNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpNamespace = ""; + + /** + * FileOptions phpMetadataNamespace. + * @member {string} phpMetadataNamespace + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.phpMetadataNamespace = ""; + + /** + * FileOptions rubyPackage. + * @member {string} rubyPackage + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.rubyPackage = ""; + + /** + * FileOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.features = null; + + /** + * FileOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FileOptions + * @instance + */ + FileOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates a new FileOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions=} [properties] Properties to set + * @returns {google.protobuf.FileOptions} FileOptions instance + */ + FileOptions.create = function create(properties) { + return new FileOptions(properties); + }; + + /** + * Encodes the specified FileOptions message. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.javaPackage != null && Object.hasOwnProperty.call(message, "javaPackage")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.javaPackage); + if (message.javaOuterClassname != null && Object.hasOwnProperty.call(message, "javaOuterClassname")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.javaOuterClassname); + if (message.optimizeFor != null && Object.hasOwnProperty.call(message, "optimizeFor")) + writer.uint32(/* id 9, wireType 0 =*/72).int32(message.optimizeFor); + if (message.javaMultipleFiles != null && Object.hasOwnProperty.call(message, "javaMultipleFiles")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.javaMultipleFiles); + if (message.goPackage != null && Object.hasOwnProperty.call(message, "goPackage")) + writer.uint32(/* id 11, wireType 2 =*/90).string(message.goPackage); + if (message.ccGenericServices != null && Object.hasOwnProperty.call(message, "ccGenericServices")) + writer.uint32(/* id 16, wireType 0 =*/128).bool(message.ccGenericServices); + if (message.javaGenericServices != null && Object.hasOwnProperty.call(message, "javaGenericServices")) + writer.uint32(/* id 17, wireType 0 =*/136).bool(message.javaGenericServices); + if (message.pyGenericServices != null && Object.hasOwnProperty.call(message, "pyGenericServices")) + writer.uint32(/* id 18, wireType 0 =*/144).bool(message.pyGenericServices); + if (message.javaGenerateEqualsAndHash != null && Object.hasOwnProperty.call(message, "javaGenerateEqualsAndHash")) + writer.uint32(/* id 20, wireType 0 =*/160).bool(message.javaGenerateEqualsAndHash); + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) + writer.uint32(/* id 23, wireType 0 =*/184).bool(message.deprecated); + if (message.javaStringCheckUtf8 != null && Object.hasOwnProperty.call(message, "javaStringCheckUtf8")) + writer.uint32(/* id 27, wireType 0 =*/216).bool(message.javaStringCheckUtf8); + if (message.ccEnableArenas != null && Object.hasOwnProperty.call(message, "ccEnableArenas")) + writer.uint32(/* id 31, wireType 0 =*/248).bool(message.ccEnableArenas); + if (message.objcClassPrefix != null && Object.hasOwnProperty.call(message, "objcClassPrefix")) + writer.uint32(/* id 36, wireType 2 =*/290).string(message.objcClassPrefix); + if (message.csharpNamespace != null && Object.hasOwnProperty.call(message, "csharpNamespace")) + writer.uint32(/* id 37, wireType 2 =*/298).string(message.csharpNamespace); + if (message.swiftPrefix != null && Object.hasOwnProperty.call(message, "swiftPrefix")) + writer.uint32(/* id 39, wireType 2 =*/314).string(message.swiftPrefix); + if (message.phpClassPrefix != null && Object.hasOwnProperty.call(message, "phpClassPrefix")) + writer.uint32(/* id 40, wireType 2 =*/322).string(message.phpClassPrefix); + if (message.phpNamespace != null && Object.hasOwnProperty.call(message, "phpNamespace")) + writer.uint32(/* id 41, wireType 2 =*/330).string(message.phpNamespace); + if (message.phpMetadataNamespace != null && Object.hasOwnProperty.call(message, "phpMetadataNamespace")) + writer.uint32(/* id 44, wireType 2 =*/354).string(message.phpMetadataNamespace); + if (message.rubyPackage != null && Object.hasOwnProperty.call(message, "rubyPackage")) + writer.uint32(/* id 45, wireType 2 =*/362).string(message.rubyPackage); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 50, wireType 2 =*/402).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FileOptions message, length delimited. Does not implicitly {@link google.protobuf.FileOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.IFileOptions} message FileOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FileOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FileOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FileOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.javaPackage = reader.string(); + break; + } + case 8: { + message.javaOuterClassname = reader.string(); + break; + } + case 10: { + message.javaMultipleFiles = reader.bool(); + break; + } + case 20: { + message.javaGenerateEqualsAndHash = reader.bool(); + break; + } + case 27: { + message.javaStringCheckUtf8 = reader.bool(); + break; + } + case 9: { + message.optimizeFor = reader.int32(); + break; + } + case 11: { + message.goPackage = reader.string(); + break; + } + case 16: { + message.ccGenericServices = reader.bool(); + break; + } + case 17: { + message.javaGenericServices = reader.bool(); + break; + } + case 18: { + message.pyGenericServices = reader.bool(); + break; + } + case 23: { + message.deprecated = reader.bool(); + break; + } + case 31: { + message.ccEnableArenas = reader.bool(); + break; + } + case 36: { + message.objcClassPrefix = reader.string(); + break; + } + case 37: { + message.csharpNamespace = reader.string(); + break; + } + case 39: { + message.swiftPrefix = reader.string(); + break; + } + case 40: { + message.phpClassPrefix = reader.string(); + break; + } + case 41: { + message.phpNamespace = reader.string(); + break; + } + case 44: { + message.phpMetadataNamespace = reader.string(); + break; + } + case 45: { + message.rubyPackage = reader.string(); + break; + } + case 50: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FileOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FileOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FileOptions} FileOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FileOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FileOptions message. + * @function verify + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FileOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + if (!$util.isString(message.javaPackage)) + return "javaPackage: string expected"; + if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + if (!$util.isString(message.javaOuterClassname)) + return "javaOuterClassname: string expected"; + if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + if (typeof message.javaMultipleFiles !== "boolean") + return "javaMultipleFiles: boolean expected"; + if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + if (typeof message.javaGenerateEqualsAndHash !== "boolean") + return "javaGenerateEqualsAndHash: boolean expected"; + if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + if (typeof message.javaStringCheckUtf8 !== "boolean") + return "javaStringCheckUtf8: boolean expected"; + if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + switch (message.optimizeFor) { + default: + return "optimizeFor: enum value expected"; + case 1: + case 2: + case 3: + break; + } + if (message.goPackage != null && message.hasOwnProperty("goPackage")) + if (!$util.isString(message.goPackage)) + return "goPackage: string expected"; + if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + if (typeof message.ccGenericServices !== "boolean") + return "ccGenericServices: boolean expected"; + if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + if (typeof message.javaGenericServices !== "boolean") + return "javaGenericServices: boolean expected"; + if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + if (typeof message.pyGenericServices !== "boolean") + return "pyGenericServices: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + if (typeof message.ccEnableArenas !== "boolean") + return "ccEnableArenas: boolean expected"; + if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + if (!$util.isString(message.objcClassPrefix)) + return "objcClassPrefix: string expected"; + if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + if (!$util.isString(message.csharpNamespace)) + return "csharpNamespace: string expected"; + if (message.swiftPrefix != null && message.hasOwnProperty("swiftPrefix")) + if (!$util.isString(message.swiftPrefix)) + return "swiftPrefix: string expected"; + if (message.phpClassPrefix != null && message.hasOwnProperty("phpClassPrefix")) + if (!$util.isString(message.phpClassPrefix)) + return "phpClassPrefix: string expected"; + if (message.phpNamespace != null && message.hasOwnProperty("phpNamespace")) + if (!$util.isString(message.phpNamespace)) + return "phpNamespace: string expected"; + if (message.phpMetadataNamespace != null && message.hasOwnProperty("phpMetadataNamespace")) + if (!$util.isString(message.phpMetadataNamespace)) + return "phpMetadataNamespace: string expected"; + if (message.rubyPackage != null && message.hasOwnProperty("rubyPackage")) + if (!$util.isString(message.rubyPackage)) + return "rubyPackage: string expected"; + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * Creates a FileOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FileOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FileOptions} FileOptions + */ + FileOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FileOptions) + return object; + var message = new $root.google.protobuf.FileOptions(); + if (object.javaPackage != null) + message.javaPackage = String(object.javaPackage); + if (object.javaOuterClassname != null) + message.javaOuterClassname = String(object.javaOuterClassname); + if (object.javaMultipleFiles != null) + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + if (object.javaGenerateEqualsAndHash != null) + message.javaGenerateEqualsAndHash = Boolean(object.javaGenerateEqualsAndHash); + if (object.javaStringCheckUtf8 != null) + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + switch (object.optimizeFor) { + default: + if (typeof object.optimizeFor === "number") { + message.optimizeFor = object.optimizeFor; + break; + } + break; + case "SPEED": + case 1: + message.optimizeFor = 1; + break; + case "CODE_SIZE": + case 2: + message.optimizeFor = 2; + break; + case "LITE_RUNTIME": + case 3: + message.optimizeFor = 3; + break; + } + if (object.goPackage != null) + message.goPackage = String(object.goPackage); + if (object.ccGenericServices != null) + message.ccGenericServices = Boolean(object.ccGenericServices); + if (object.javaGenericServices != null) + message.javaGenericServices = Boolean(object.javaGenericServices); + if (object.pyGenericServices != null) + message.pyGenericServices = Boolean(object.pyGenericServices); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.ccEnableArenas != null) + message.ccEnableArenas = Boolean(object.ccEnableArenas); + if (object.objcClassPrefix != null) + message.objcClassPrefix = String(object.objcClassPrefix); + if (object.csharpNamespace != null) + message.csharpNamespace = String(object.csharpNamespace); + if (object.swiftPrefix != null) + message.swiftPrefix = String(object.swiftPrefix); + if (object.phpClassPrefix != null) + message.phpClassPrefix = String(object.phpClassPrefix); + if (object.phpNamespace != null) + message.phpNamespace = String(object.phpNamespace); + if (object.phpMetadataNamespace != null) + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + if (object.rubyPackage != null) + message.rubyPackage = String(object.rubyPackage); + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.FileOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FileOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a FileOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FileOptions + * @static + * @param {google.protobuf.FileOptions} message FileOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FileOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.javaPackage = ""; + object.javaOuterClassname = ""; + object.optimizeFor = options.enums === String ? "SPEED" : 1; + object.javaMultipleFiles = false; + object.goPackage = ""; + object.ccGenericServices = false; + object.javaGenericServices = false; + object.pyGenericServices = false; + object.javaGenerateEqualsAndHash = false; + object.deprecated = false; + object.javaStringCheckUtf8 = false; + object.ccEnableArenas = true; + object.objcClassPrefix = ""; + object.csharpNamespace = ""; + object.swiftPrefix = ""; + object.phpClassPrefix = ""; + object.phpNamespace = ""; + object.phpMetadataNamespace = ""; + object.rubyPackage = ""; + object.features = null; + } + if (message.javaPackage != null && message.hasOwnProperty("javaPackage")) + object.javaPackage = message.javaPackage; + if (message.javaOuterClassname != null && message.hasOwnProperty("javaOuterClassname")) + object.javaOuterClassname = message.javaOuterClassname; + if (message.optimizeFor != null && message.hasOwnProperty("optimizeFor")) + object.optimizeFor = options.enums === String ? $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] === undefined ? message.optimizeFor : $root.google.protobuf.FileOptions.OptimizeMode[message.optimizeFor] : message.optimizeFor; + if (message.javaMultipleFiles != null && message.hasOwnProperty("javaMultipleFiles")) + object.javaMultipleFiles = message.javaMultipleFiles; + if (message.goPackage != null && message.hasOwnProperty("goPackage")) + object.goPackage = message.goPackage; + if (message.ccGenericServices != null && message.hasOwnProperty("ccGenericServices")) + object.ccGenericServices = message.ccGenericServices; + if (message.javaGenericServices != null && message.hasOwnProperty("javaGenericServices")) + object.javaGenericServices = message.javaGenericServices; + if (message.pyGenericServices != null && message.hasOwnProperty("pyGenericServices")) + object.pyGenericServices = message.pyGenericServices; + if (message.javaGenerateEqualsAndHash != null && message.hasOwnProperty("javaGenerateEqualsAndHash")) + object.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.javaStringCheckUtf8 != null && message.hasOwnProperty("javaStringCheckUtf8")) + object.javaStringCheckUtf8 = message.javaStringCheckUtf8; + if (message.ccEnableArenas != null && message.hasOwnProperty("ccEnableArenas")) + object.ccEnableArenas = message.ccEnableArenas; + if (message.objcClassPrefix != null && message.hasOwnProperty("objcClassPrefix")) + object.objcClassPrefix = message.objcClassPrefix; + if (message.csharpNamespace != null && message.hasOwnProperty("csharpNamespace")) + object.csharpNamespace = message.csharpNamespace; + if (message.swiftPrefix != null && message.hasOwnProperty("swiftPrefix")) + object.swiftPrefix = message.swiftPrefix; + if (message.phpClassPrefix != null && message.hasOwnProperty("phpClassPrefix")) + object.phpClassPrefix = message.phpClassPrefix; + if (message.phpNamespace != null && message.hasOwnProperty("phpNamespace")) + object.phpNamespace = message.phpNamespace; + if (message.phpMetadataNamespace != null && message.hasOwnProperty("phpMetadataNamespace")) + object.phpMetadataNamespace = message.phpMetadataNamespace; + if (message.rubyPackage != null && message.hasOwnProperty("rubyPackage")) + object.rubyPackage = message.rubyPackage; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this FileOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FileOptions + * @instance + * @returns {Object.} JSON object + */ + FileOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FileOptions + * @function getTypeUrl + * @memberof google.protobuf.FileOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FileOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FileOptions"; + }; + + /** + * OptimizeMode enum. + * @name google.protobuf.FileOptions.OptimizeMode + * @enum {number} + * @property {number} SPEED=1 SPEED value + * @property {number} CODE_SIZE=2 CODE_SIZE value + * @property {number} LITE_RUNTIME=3 LITE_RUNTIME value + */ + FileOptions.OptimizeMode = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[1] = "SPEED"] = 1; + values[valuesById[2] = "CODE_SIZE"] = 2; + values[valuesById[3] = "LITE_RUNTIME"] = 3; + return values; + })(); + + return FileOptions; + })(); + + protobuf.MessageOptions = (function() { + + /** + * Properties of a MessageOptions. + * @memberof google.protobuf + * @interface IMessageOptions + * @property {boolean|null} [messageSetWireFormat] MessageOptions messageSetWireFormat + * @property {boolean|null} [noStandardDescriptorAccessor] MessageOptions noStandardDescriptorAccessor + * @property {boolean|null} [deprecated] MessageOptions deprecated + * @property {boolean|null} [mapEntry] MessageOptions mapEntry + * @property {boolean|null} [deprecatedLegacyJsonFieldConflicts] MessageOptions deprecatedLegacyJsonFieldConflicts + * @property {google.protobuf.IFeatureSet|null} [features] MessageOptions features + * @property {Array.|null} [uninterpretedOption] MessageOptions uninterpretedOption + */ + + /** + * Constructs a new MessageOptions. + * @memberof google.protobuf + * @classdesc Represents a MessageOptions. + * @implements IMessageOptions + * @constructor + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + */ + function MessageOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MessageOptions messageSetWireFormat. + * @member {boolean} messageSetWireFormat + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.messageSetWireFormat = false; + + /** + * MessageOptions noStandardDescriptorAccessor. + * @member {boolean} noStandardDescriptorAccessor + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.noStandardDescriptorAccessor = false; + + /** + * MessageOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecated = false; + + /** + * MessageOptions mapEntry. + * @member {boolean} mapEntry + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.mapEntry = false; + + /** + * MessageOptions deprecatedLegacyJsonFieldConflicts. + * @member {boolean} deprecatedLegacyJsonFieldConflicts + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.deprecatedLegacyJsonFieldConflicts = false; + + /** + * MessageOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.features = null; + + /** + * MessageOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MessageOptions + * @instance + */ + MessageOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates a new MessageOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions=} [properties] Properties to set + * @returns {google.protobuf.MessageOptions} MessageOptions instance + */ + MessageOptions.create = function create(properties) { + return new MessageOptions(properties); + }; + + /** + * Encodes the specified MessageOptions message. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.messageSetWireFormat != null && Object.hasOwnProperty.call(message, "messageSetWireFormat")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.messageSetWireFormat); + if (message.noStandardDescriptorAccessor != null && Object.hasOwnProperty.call(message, "noStandardDescriptorAccessor")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.noStandardDescriptorAccessor); + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); + if (message.mapEntry != null && Object.hasOwnProperty.call(message, "mapEntry")) + writer.uint32(/* id 7, wireType 0 =*/56).bool(message.mapEntry); + if (message.deprecatedLegacyJsonFieldConflicts != null && Object.hasOwnProperty.call(message, "deprecatedLegacyJsonFieldConflicts")) + writer.uint32(/* id 11, wireType 0 =*/88).bool(message.deprecatedLegacyJsonFieldConflicts); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 12, wireType 2 =*/98).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MessageOptions message, length delimited. Does not implicitly {@link google.protobuf.MessageOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.IMessageOptions} message MessageOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MessageOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MessageOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.MessageOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.messageSetWireFormat = reader.bool(); + break; + } + case 2: { + message.noStandardDescriptorAccessor = reader.bool(); + break; + } + case 3: { + message.deprecated = reader.bool(); + break; + } + case 7: { + message.mapEntry = reader.bool(); + break; + } + case 11: { + message.deprecatedLegacyJsonFieldConflicts = reader.bool(); + break; + } + case 12: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MessageOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MessageOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MessageOptions} MessageOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MessageOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MessageOptions message. + * @function verify + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MessageOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + if (typeof message.messageSetWireFormat !== "boolean") + return "messageSetWireFormat: boolean expected"; + if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + if (typeof message.noStandardDescriptorAccessor !== "boolean") + return "noStandardDescriptorAccessor: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + if (typeof message.mapEntry !== "boolean") + return "mapEntry: boolean expected"; + if (message.deprecatedLegacyJsonFieldConflicts != null && message.hasOwnProperty("deprecatedLegacyJsonFieldConflicts")) + if (typeof message.deprecatedLegacyJsonFieldConflicts !== "boolean") + return "deprecatedLegacyJsonFieldConflicts: boolean expected"; + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * Creates a MessageOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MessageOptions} MessageOptions + */ + MessageOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MessageOptions) + return object; + var message = new $root.google.protobuf.MessageOptions(); + if (object.messageSetWireFormat != null) + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + if (object.noStandardDescriptorAccessor != null) + message.noStandardDescriptorAccessor = Boolean(object.noStandardDescriptorAccessor); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.mapEntry != null) + message.mapEntry = Boolean(object.mapEntry); + if (object.deprecatedLegacyJsonFieldConflicts != null) + message.deprecatedLegacyJsonFieldConflicts = Boolean(object.deprecatedLegacyJsonFieldConflicts); + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.MessageOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MessageOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a MessageOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MessageOptions + * @static + * @param {google.protobuf.MessageOptions} message MessageOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MessageOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.messageSetWireFormat = false; + object.noStandardDescriptorAccessor = false; + object.deprecated = false; + object.mapEntry = false; + object.deprecatedLegacyJsonFieldConflicts = false; + object.features = null; + } + if (message.messageSetWireFormat != null && message.hasOwnProperty("messageSetWireFormat")) + object.messageSetWireFormat = message.messageSetWireFormat; + if (message.noStandardDescriptorAccessor != null && message.hasOwnProperty("noStandardDescriptorAccessor")) + object.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.mapEntry != null && message.hasOwnProperty("mapEntry")) + object.mapEntry = message.mapEntry; + if (message.deprecatedLegacyJsonFieldConflicts != null && message.hasOwnProperty("deprecatedLegacyJsonFieldConflicts")) + object.deprecatedLegacyJsonFieldConflicts = message.deprecatedLegacyJsonFieldConflicts; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this MessageOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MessageOptions + * @instance + * @returns {Object.} JSON object + */ + MessageOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MessageOptions + * @function getTypeUrl + * @memberof google.protobuf.MessageOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MessageOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MessageOptions"; + }; + + return MessageOptions; + })(); + + protobuf.FieldOptions = (function() { + + /** + * Properties of a FieldOptions. + * @memberof google.protobuf + * @interface IFieldOptions + * @property {google.protobuf.FieldOptions.CType|null} [ctype] FieldOptions ctype + * @property {boolean|null} [packed] FieldOptions packed + * @property {google.protobuf.FieldOptions.JSType|null} [jstype] FieldOptions jstype + * @property {boolean|null} [lazy] FieldOptions lazy + * @property {boolean|null} [unverifiedLazy] FieldOptions unverifiedLazy + * @property {boolean|null} [deprecated] FieldOptions deprecated + * @property {boolean|null} [weak] FieldOptions weak + * @property {boolean|null} [debugRedact] FieldOptions debugRedact + * @property {google.protobuf.FieldOptions.OptionRetention|null} [retention] FieldOptions retention + * @property {Array.|null} [targets] FieldOptions targets + * @property {Array.|null} [editionDefaults] FieldOptions editionDefaults + * @property {google.protobuf.IFeatureSet|null} [features] FieldOptions features + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] FieldOptions featureSupport + * @property {Array.|null} [uninterpretedOption] FieldOptions uninterpretedOption + * @property {Array.|null} [".google.api.fieldBehavior"] FieldOptions .google.api.fieldBehavior + */ + + /** + * Constructs a new FieldOptions. + * @memberof google.protobuf + * @classdesc Represents a FieldOptions. + * @implements IFieldOptions + * @constructor + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + */ + function FieldOptions(properties) { + this.targets = []; + this.editionDefaults = []; + this.uninterpretedOption = []; + this[".google.api.fieldBehavior"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FieldOptions ctype. + * @member {google.protobuf.FieldOptions.CType} ctype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.ctype = 0; + + /** + * FieldOptions packed. + * @member {boolean} packed + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.packed = false; + + /** + * FieldOptions jstype. + * @member {google.protobuf.FieldOptions.JSType} jstype + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.jstype = 0; + + /** + * FieldOptions lazy. + * @member {boolean} lazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.lazy = false; + + /** + * FieldOptions unverifiedLazy. + * @member {boolean} unverifiedLazy + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.unverifiedLazy = false; + + /** + * FieldOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.deprecated = false; + + /** + * FieldOptions weak. + * @member {boolean} weak + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.weak = false; + + /** + * FieldOptions debugRedact. + * @member {boolean} debugRedact + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.debugRedact = false; + + /** + * FieldOptions retention. + * @member {google.protobuf.FieldOptions.OptionRetention} retention + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.retention = 0; + + /** + * FieldOptions targets. + * @member {Array.} targets + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.targets = $util.emptyArray; + + /** + * FieldOptions editionDefaults. + * @member {Array.} editionDefaults + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.editionDefaults = $util.emptyArray; + + /** + * FieldOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.features = null; + + /** + * FieldOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.featureSupport = null; + + /** + * FieldOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * FieldOptions .google.api.fieldBehavior. + * @member {Array.} .google.api.fieldBehavior + * @memberof google.protobuf.FieldOptions + * @instance + */ + FieldOptions.prototype[".google.api.fieldBehavior"] = $util.emptyArray; + + /** + * Creates a new FieldOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions} FieldOptions instance + */ + FieldOptions.create = function create(properties) { + return new FieldOptions(properties); + }; + + /** + * Encodes the specified FieldOptions message. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.ctype != null && Object.hasOwnProperty.call(message, "ctype")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.ctype); + if (message.packed != null && Object.hasOwnProperty.call(message, "packed")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.packed); + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); + if (message.lazy != null && Object.hasOwnProperty.call(message, "lazy")) + writer.uint32(/* id 5, wireType 0 =*/40).bool(message.lazy); + if (message.jstype != null && Object.hasOwnProperty.call(message, "jstype")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jstype); + if (message.weak != null && Object.hasOwnProperty.call(message, "weak")) + writer.uint32(/* id 10, wireType 0 =*/80).bool(message.weak); + if (message.unverifiedLazy != null && Object.hasOwnProperty.call(message, "unverifiedLazy")) + writer.uint32(/* id 15, wireType 0 =*/120).bool(message.unverifiedLazy); + if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) + writer.uint32(/* id 16, wireType 0 =*/128).bool(message.debugRedact); + if (message.retention != null && Object.hasOwnProperty.call(message, "retention")) + writer.uint32(/* id 17, wireType 0 =*/136).int32(message.retention); + if (message.targets != null && message.targets.length) + for (var i = 0; i < message.targets.length; ++i) + writer.uint32(/* id 19, wireType 0 =*/152).int32(message.targets[i]); + if (message.editionDefaults != null && message.editionDefaults.length) + for (var i = 0; i < message.editionDefaults.length; ++i) + $root.google.protobuf.FieldOptions.EditionDefault.encode(message.editionDefaults[i], writer.uint32(/* id 20, wireType 2 =*/162).fork()).ldelim(); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 21, wireType 2 =*/170).fork()).ldelim(); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 22, wireType 2 =*/178).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + if (message[".google.api.fieldBehavior"] != null && message[".google.api.fieldBehavior"].length) + for (var i = 0; i < message[".google.api.fieldBehavior"].length; ++i) + writer.uint32(/* id 1052, wireType 0 =*/8416).int32(message[".google.api.fieldBehavior"][i]); + return writer; + }; + + /** + * Encodes the specified FieldOptions message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.IFieldOptions} message FieldOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FieldOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FieldOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.ctype = reader.int32(); + break; + } + case 2: { + message.packed = reader.bool(); + break; + } + case 6: { + message.jstype = reader.int32(); + break; + } + case 5: { + message.lazy = reader.bool(); + break; + } + case 15: { + message.unverifiedLazy = reader.bool(); + break; + } + case 3: { + message.deprecated = reader.bool(); + break; + } + case 10: { + message.weak = reader.bool(); + break; + } + case 16: { + message.debugRedact = reader.bool(); + break; + } + case 17: { + message.retention = reader.int32(); + break; + } + case 19: { + if (!(message.targets && message.targets.length)) + message.targets = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.targets.push(reader.int32()); + } else + message.targets.push(reader.int32()); + break; + } + case 20: { + if (!(message.editionDefaults && message.editionDefaults.length)) + message.editionDefaults = []; + message.editionDefaults.push($root.google.protobuf.FieldOptions.EditionDefault.decode(reader, reader.uint32())); + break; + } + case 21: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 22: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1052: { + if (!(message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length)) + message[".google.api.fieldBehavior"] = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message[".google.api.fieldBehavior"].push(reader.int32()); + } else + message[".google.api.fieldBehavior"].push(reader.int32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FieldOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions} FieldOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FieldOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FieldOptions message. + * @function verify + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FieldOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.ctype != null && message.hasOwnProperty("ctype")) + switch (message.ctype) { + default: + return "ctype: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.packed != null && message.hasOwnProperty("packed")) + if (typeof message.packed !== "boolean") + return "packed: boolean expected"; + if (message.jstype != null && message.hasOwnProperty("jstype")) + switch (message.jstype) { + default: + return "jstype: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.lazy != null && message.hasOwnProperty("lazy")) + if (typeof message.lazy !== "boolean") + return "lazy: boolean expected"; + if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) + if (typeof message.unverifiedLazy !== "boolean") + return "unverifiedLazy: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.weak != null && message.hasOwnProperty("weak")) + if (typeof message.weak !== "boolean") + return "weak: boolean expected"; + if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) + if (typeof message.debugRedact !== "boolean") + return "debugRedact: boolean expected"; + if (message.retention != null && message.hasOwnProperty("retention")) + switch (message.retention) { + default: + return "retention: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.targets != null && message.hasOwnProperty("targets")) { + if (!Array.isArray(message.targets)) + return "targets: array expected"; + for (var i = 0; i < message.targets.length; ++i) + switch (message.targets[i]) { + default: + return "targets: enum value[] expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + break; + } + } + if (message.editionDefaults != null && message.hasOwnProperty("editionDefaults")) { + if (!Array.isArray(message.editionDefaults)) + return "editionDefaults: array expected"; + for (var i = 0; i < message.editionDefaults.length; ++i) { + var error = $root.google.protobuf.FieldOptions.EditionDefault.verify(message.editionDefaults[i]); + if (error) + return "editionDefaults." + error; + } + } + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + if (message[".google.api.fieldBehavior"] != null && message.hasOwnProperty(".google.api.fieldBehavior")) { + if (!Array.isArray(message[".google.api.fieldBehavior"])) + return ".google.api.fieldBehavior: array expected"; + for (var i = 0; i < message[".google.api.fieldBehavior"].length; ++i) + switch (message[".google.api.fieldBehavior"][i]) { + default: + return ".google.api.fieldBehavior: enum value[] expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + break; + } + } + return null; + }; + + /** + * Creates a FieldOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions} FieldOptions + */ + FieldOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions) + return object; + var message = new $root.google.protobuf.FieldOptions(); + switch (object.ctype) { + default: + if (typeof object.ctype === "number") { + message.ctype = object.ctype; + break; + } + break; + case "STRING": + case 0: + message.ctype = 0; + break; + case "CORD": + case 1: + message.ctype = 1; + break; + case "STRING_PIECE": + case 2: + message.ctype = 2; + break; + } + if (object.packed != null) + message.packed = Boolean(object.packed); + switch (object.jstype) { + default: + if (typeof object.jstype === "number") { + message.jstype = object.jstype; + break; + } + break; + case "JS_NORMAL": + case 0: + message.jstype = 0; + break; + case "JS_STRING": + case 1: + message.jstype = 1; + break; + case "JS_NUMBER": + case 2: + message.jstype = 2; + break; + } + if (object.lazy != null) + message.lazy = Boolean(object.lazy); + if (object.unverifiedLazy != null) + message.unverifiedLazy = Boolean(object.unverifiedLazy); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.weak != null) + message.weak = Boolean(object.weak); + if (object.debugRedact != null) + message.debugRedact = Boolean(object.debugRedact); + switch (object.retention) { + default: + if (typeof object.retention === "number") { + message.retention = object.retention; + break; + } + break; + case "RETENTION_UNKNOWN": + case 0: + message.retention = 0; + break; + case "RETENTION_RUNTIME": + case 1: + message.retention = 1; + break; + case "RETENTION_SOURCE": + case 2: + message.retention = 2; + break; + } + if (object.targets) { + if (!Array.isArray(object.targets)) + throw TypeError(".google.protobuf.FieldOptions.targets: array expected"); + message.targets = []; + for (var i = 0; i < object.targets.length; ++i) + switch (object.targets[i]) { + default: + if (typeof object.targets[i] === "number") { + message.targets[i] = object.targets[i]; + break; + } + case "TARGET_TYPE_UNKNOWN": + case 0: + message.targets[i] = 0; + break; + case "TARGET_TYPE_FILE": + case 1: + message.targets[i] = 1; + break; + case "TARGET_TYPE_EXTENSION_RANGE": + case 2: + message.targets[i] = 2; + break; + case "TARGET_TYPE_MESSAGE": + case 3: + message.targets[i] = 3; + break; + case "TARGET_TYPE_FIELD": + case 4: + message.targets[i] = 4; + break; + case "TARGET_TYPE_ONEOF": + case 5: + message.targets[i] = 5; + break; + case "TARGET_TYPE_ENUM": + case 6: + message.targets[i] = 6; + break; + case "TARGET_TYPE_ENUM_ENTRY": + case 7: + message.targets[i] = 7; + break; + case "TARGET_TYPE_SERVICE": + case 8: + message.targets[i] = 8; + break; + case "TARGET_TYPE_METHOD": + case 9: + message.targets[i] = 9; + break; + } + } + if (object.editionDefaults) { + if (!Array.isArray(object.editionDefaults)) + throw TypeError(".google.protobuf.FieldOptions.editionDefaults: array expected"); + message.editionDefaults = []; + for (var i = 0; i < object.editionDefaults.length; ++i) { + if (typeof object.editionDefaults[i] !== "object") + throw TypeError(".google.protobuf.FieldOptions.editionDefaults: object expected"); + message.editionDefaults[i] = $root.google.protobuf.FieldOptions.EditionDefault.fromObject(object.editionDefaults[i]); + } + } + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.FieldOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.FieldOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.FieldOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.fieldBehavior"]) { + if (!Array.isArray(object[".google.api.fieldBehavior"])) + throw TypeError(".google.protobuf.FieldOptions..google.api.fieldBehavior: array expected"); + message[".google.api.fieldBehavior"] = []; + for (var i = 0; i < object[".google.api.fieldBehavior"].length; ++i) + switch (object[".google.api.fieldBehavior"][i]) { + default: + if (typeof object[".google.api.fieldBehavior"][i] === "number") { + message[".google.api.fieldBehavior"][i] = object[".google.api.fieldBehavior"][i]; + break; + } + case "FIELD_BEHAVIOR_UNSPECIFIED": + case 0: + message[".google.api.fieldBehavior"][i] = 0; + break; + case "OPTIONAL": + case 1: + message[".google.api.fieldBehavior"][i] = 1; + break; + case "REQUIRED": + case 2: + message[".google.api.fieldBehavior"][i] = 2; + break; + case "OUTPUT_ONLY": + case 3: + message[".google.api.fieldBehavior"][i] = 3; + break; + case "INPUT_ONLY": + case 4: + message[".google.api.fieldBehavior"][i] = 4; + break; + case "IMMUTABLE": + case 5: + message[".google.api.fieldBehavior"][i] = 5; + break; + case "UNORDERED_LIST": + case 6: + message[".google.api.fieldBehavior"][i] = 6; + break; + case "NON_EMPTY_DEFAULT": + case 7: + message[".google.api.fieldBehavior"][i] = 7; + break; + case "IDENTIFIER": + case 8: + message[".google.api.fieldBehavior"][i] = 8; + break; + } + } + return message; + }; + + /** + * Creates a plain object from a FieldOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions + * @static + * @param {google.protobuf.FieldOptions} message FieldOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FieldOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.targets = []; + object.editionDefaults = []; + object.uninterpretedOption = []; + object[".google.api.fieldBehavior"] = []; + } + if (options.defaults) { + object.ctype = options.enums === String ? "STRING" : 0; + object.packed = false; + object.deprecated = false; + object.lazy = false; + object.jstype = options.enums === String ? "JS_NORMAL" : 0; + object.weak = false; + object.unverifiedLazy = false; + object.debugRedact = false; + object.retention = options.enums === String ? "RETENTION_UNKNOWN" : 0; + object.features = null; + object.featureSupport = null; + } + if (message.ctype != null && message.hasOwnProperty("ctype")) + object.ctype = options.enums === String ? $root.google.protobuf.FieldOptions.CType[message.ctype] === undefined ? message.ctype : $root.google.protobuf.FieldOptions.CType[message.ctype] : message.ctype; + if (message.packed != null && message.hasOwnProperty("packed")) + object.packed = message.packed; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.lazy != null && message.hasOwnProperty("lazy")) + object.lazy = message.lazy; + if (message.jstype != null && message.hasOwnProperty("jstype")) + object.jstype = options.enums === String ? $root.google.protobuf.FieldOptions.JSType[message.jstype] === undefined ? message.jstype : $root.google.protobuf.FieldOptions.JSType[message.jstype] : message.jstype; + if (message.weak != null && message.hasOwnProperty("weak")) + object.weak = message.weak; + if (message.unverifiedLazy != null && message.hasOwnProperty("unverifiedLazy")) + object.unverifiedLazy = message.unverifiedLazy; + if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) + object.debugRedact = message.debugRedact; + if (message.retention != null && message.hasOwnProperty("retention")) + object.retention = options.enums === String ? $root.google.protobuf.FieldOptions.OptionRetention[message.retention] === undefined ? message.retention : $root.google.protobuf.FieldOptions.OptionRetention[message.retention] : message.retention; + if (message.targets && message.targets.length) { + object.targets = []; + for (var j = 0; j < message.targets.length; ++j) + object.targets[j] = options.enums === String ? $root.google.protobuf.FieldOptions.OptionTargetType[message.targets[j]] === undefined ? message.targets[j] : $root.google.protobuf.FieldOptions.OptionTargetType[message.targets[j]] : message.targets[j]; + } + if (message.editionDefaults && message.editionDefaults.length) { + object.editionDefaults = []; + for (var j = 0; j < message.editionDefaults.length; ++j) + object.editionDefaults[j] = $root.google.protobuf.FieldOptions.EditionDefault.toObject(message.editionDefaults[j], options); + } + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.fieldBehavior"] && message[".google.api.fieldBehavior"].length) { + object[".google.api.fieldBehavior"] = []; + for (var j = 0; j < message[".google.api.fieldBehavior"].length; ++j) + object[".google.api.fieldBehavior"][j] = options.enums === String ? $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] === undefined ? message[".google.api.fieldBehavior"][j] : $root.google.api.FieldBehavior[message[".google.api.fieldBehavior"][j]] : message[".google.api.fieldBehavior"][j]; + } + return object; + }; + + /** + * Converts this FieldOptions to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions + * @instance + * @returns {Object.} JSON object + */ + FieldOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FieldOptions + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FieldOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions"; + }; + + /** + * CType enum. + * @name google.protobuf.FieldOptions.CType + * @enum {number} + * @property {number} STRING=0 STRING value + * @property {number} CORD=1 CORD value + * @property {number} STRING_PIECE=2 STRING_PIECE value + */ + FieldOptions.CType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STRING"] = 0; + values[valuesById[1] = "CORD"] = 1; + values[valuesById[2] = "STRING_PIECE"] = 2; + return values; + })(); + + /** + * JSType enum. + * @name google.protobuf.FieldOptions.JSType + * @enum {number} + * @property {number} JS_NORMAL=0 JS_NORMAL value + * @property {number} JS_STRING=1 JS_STRING value + * @property {number} JS_NUMBER=2 JS_NUMBER value + */ + FieldOptions.JSType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JS_NORMAL"] = 0; + values[valuesById[1] = "JS_STRING"] = 1; + values[valuesById[2] = "JS_NUMBER"] = 2; + return values; + })(); + + /** + * OptionRetention enum. + * @name google.protobuf.FieldOptions.OptionRetention + * @enum {number} + * @property {number} RETENTION_UNKNOWN=0 RETENTION_UNKNOWN value + * @property {number} RETENTION_RUNTIME=1 RETENTION_RUNTIME value + * @property {number} RETENTION_SOURCE=2 RETENTION_SOURCE value + */ + FieldOptions.OptionRetention = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "RETENTION_UNKNOWN"] = 0; + values[valuesById[1] = "RETENTION_RUNTIME"] = 1; + values[valuesById[2] = "RETENTION_SOURCE"] = 2; + return values; + })(); + + /** + * OptionTargetType enum. + * @name google.protobuf.FieldOptions.OptionTargetType + * @enum {number} + * @property {number} TARGET_TYPE_UNKNOWN=0 TARGET_TYPE_UNKNOWN value + * @property {number} TARGET_TYPE_FILE=1 TARGET_TYPE_FILE value + * @property {number} TARGET_TYPE_EXTENSION_RANGE=2 TARGET_TYPE_EXTENSION_RANGE value + * @property {number} TARGET_TYPE_MESSAGE=3 TARGET_TYPE_MESSAGE value + * @property {number} TARGET_TYPE_FIELD=4 TARGET_TYPE_FIELD value + * @property {number} TARGET_TYPE_ONEOF=5 TARGET_TYPE_ONEOF value + * @property {number} TARGET_TYPE_ENUM=6 TARGET_TYPE_ENUM value + * @property {number} TARGET_TYPE_ENUM_ENTRY=7 TARGET_TYPE_ENUM_ENTRY value + * @property {number} TARGET_TYPE_SERVICE=8 TARGET_TYPE_SERVICE value + * @property {number} TARGET_TYPE_METHOD=9 TARGET_TYPE_METHOD value + */ + FieldOptions.OptionTargetType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "TARGET_TYPE_UNKNOWN"] = 0; + values[valuesById[1] = "TARGET_TYPE_FILE"] = 1; + values[valuesById[2] = "TARGET_TYPE_EXTENSION_RANGE"] = 2; + values[valuesById[3] = "TARGET_TYPE_MESSAGE"] = 3; + values[valuesById[4] = "TARGET_TYPE_FIELD"] = 4; + values[valuesById[5] = "TARGET_TYPE_ONEOF"] = 5; + values[valuesById[6] = "TARGET_TYPE_ENUM"] = 6; + values[valuesById[7] = "TARGET_TYPE_ENUM_ENTRY"] = 7; + values[valuesById[8] = "TARGET_TYPE_SERVICE"] = 8; + values[valuesById[9] = "TARGET_TYPE_METHOD"] = 9; + return values; + })(); + + FieldOptions.EditionDefault = (function() { + + /** + * Properties of an EditionDefault. + * @memberof google.protobuf.FieldOptions + * @interface IEditionDefault + * @property {google.protobuf.Edition|null} [edition] EditionDefault edition + * @property {string|null} [value] EditionDefault value + */ + + /** + * Constructs a new EditionDefault. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents an EditionDefault. + * @implements IEditionDefault + * @constructor + * @param {google.protobuf.FieldOptions.IEditionDefault=} [properties] Properties to set + */ + function EditionDefault(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EditionDefault edition. + * @member {google.protobuf.Edition} edition + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + */ + EditionDefault.prototype.edition = 0; + + /** + * EditionDefault value. + * @member {string} value + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + */ + EditionDefault.prototype.value = ""; + + /** + * Creates a new EditionDefault instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.IEditionDefault=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault instance + */ + EditionDefault.create = function create(properties) { + return new EditionDefault(properties); + }; + + /** + * Encodes the specified EditionDefault message. Does not implicitly {@link google.protobuf.FieldOptions.EditionDefault.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.IEditionDefault} message EditionDefault message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EditionDefault.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.value); + if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + return writer; + }; + + /** + * Encodes the specified EditionDefault message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.EditionDefault.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.IEditionDefault} message EditionDefault message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EditionDefault.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EditionDefault message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EditionDefault.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.EditionDefault(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.edition = reader.int32(); + break; + } + case 2: { + message.value = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EditionDefault message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EditionDefault.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EditionDefault message. + * @function verify + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EditionDefault.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.edition != null && message.hasOwnProperty("edition")) + switch (message.edition) { + default: + return "edition: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + return null; + }; + + /** + * Creates an EditionDefault message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.EditionDefault} EditionDefault + */ + EditionDefault.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.EditionDefault) + return object; + var message = new $root.google.protobuf.FieldOptions.EditionDefault(); + switch (object.edition) { + default: + if (typeof object.edition === "number") { + message.edition = object.edition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.edition = 0; + break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from an EditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {google.protobuf.FieldOptions.EditionDefault} message EditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.value = ""; + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + return object; + }; + + /** + * Converts this EditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.EditionDefault + * @instance + * @returns {Object.} JSON object + */ + EditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.EditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.EditionDefault"; + }; + + return EditionDefault; + })(); + + FieldOptions.FeatureSupport = (function() { + + /** + * Properties of a FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @interface IFeatureSupport + * @property {google.protobuf.Edition|null} [editionIntroduced] FeatureSupport editionIntroduced + * @property {google.protobuf.Edition|null} [editionDeprecated] FeatureSupport editionDeprecated + * @property {string|null} [deprecationWarning] FeatureSupport deprecationWarning + * @property {google.protobuf.Edition|null} [editionRemoved] FeatureSupport editionRemoved + */ + + /** + * Constructs a new FeatureSupport. + * @memberof google.protobuf.FieldOptions + * @classdesc Represents a FeatureSupport. + * @implements IFeatureSupport + * @constructor + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + */ + function FeatureSupport(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FeatureSupport editionIntroduced. + * @member {google.protobuf.Edition} editionIntroduced + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionIntroduced = 0; + + /** + * FeatureSupport editionDeprecated. + * @member {google.protobuf.Edition} editionDeprecated + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionDeprecated = 0; + + /** + * FeatureSupport deprecationWarning. + * @member {string} deprecationWarning + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.deprecationWarning = ""; + + /** + * FeatureSupport editionRemoved. + * @member {google.protobuf.Edition} editionRemoved + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + */ + FeatureSupport.prototype.editionRemoved = 0; + + /** + * Creates a new FeatureSupport instance using the specified properties. + * @function create + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport=} [properties] Properties to set + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport instance + */ + FeatureSupport.create = function create(properties) { + return new FeatureSupport(properties); + }; + + /** + * Encodes the specified FeatureSupport message. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.editionIntroduced != null && Object.hasOwnProperty.call(message, "editionIntroduced")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.editionIntroduced); + if (message.editionDeprecated != null && Object.hasOwnProperty.call(message, "editionDeprecated")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.editionDeprecated); + if (message.deprecationWarning != null && Object.hasOwnProperty.call(message, "deprecationWarning")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.deprecationWarning); + if (message.editionRemoved != null && Object.hasOwnProperty.call(message, "editionRemoved")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.editionRemoved); + return writer; + }; + + /** + * Encodes the specified FeatureSupport message, length delimited. Does not implicitly {@link google.protobuf.FieldOptions.FeatureSupport.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.IFeatureSupport} message FeatureSupport message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSupport.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.editionIntroduced = reader.int32(); + break; + } + case 2: { + message.editionDeprecated = reader.int32(); + break; + } + case 3: { + message.deprecationWarning = reader.string(); + break; + } + case 4: { + message.editionRemoved = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSupport message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSupport.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSupport message. + * @function verify + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSupport.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + switch (message.editionIntroduced) { + default: + return "editionIntroduced: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + switch (message.editionDeprecated) { + default: + return "editionDeprecated: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + if (!$util.isString(message.deprecationWarning)) + return "deprecationWarning: string expected"; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + switch (message.editionRemoved) { + default: + return "editionRemoved: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSupport message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FieldOptions.FeatureSupport} FeatureSupport + */ + FeatureSupport.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FieldOptions.FeatureSupport) + return object; + var message = new $root.google.protobuf.FieldOptions.FeatureSupport(); + switch (object.editionIntroduced) { + default: + if (typeof object.editionIntroduced === "number") { + message.editionIntroduced = object.editionIntroduced; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionIntroduced = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionIntroduced = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionIntroduced = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionIntroduced = 999; + break; + case "EDITION_2023": + case 1000: + message.editionIntroduced = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionIntroduced = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionIntroduced = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionIntroduced = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionIntroduced = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionIntroduced = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionIntroduced = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionIntroduced = 2147483647; + break; + } + switch (object.editionDeprecated) { + default: + if (typeof object.editionDeprecated === "number") { + message.editionDeprecated = object.editionDeprecated; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionDeprecated = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionDeprecated = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionDeprecated = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionDeprecated = 999; + break; + case "EDITION_2023": + case 1000: + message.editionDeprecated = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionDeprecated = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionDeprecated = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionDeprecated = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionDeprecated = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionDeprecated = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionDeprecated = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionDeprecated = 2147483647; + break; + } + if (object.deprecationWarning != null) + message.deprecationWarning = String(object.deprecationWarning); + switch (object.editionRemoved) { + default: + if (typeof object.editionRemoved === "number") { + message.editionRemoved = object.editionRemoved; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.editionRemoved = 0; + break; + case "EDITION_LEGACY": + case 900: + message.editionRemoved = 900; + break; + case "EDITION_PROTO2": + case 998: + message.editionRemoved = 998; + break; + case "EDITION_PROTO3": + case 999: + message.editionRemoved = 999; + break; + case "EDITION_2023": + case 1000: + message.editionRemoved = 1000; + break; + case "EDITION_2024": + case 1001: + message.editionRemoved = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.editionRemoved = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.editionRemoved = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.editionRemoved = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.editionRemoved = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.editionRemoved = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.editionRemoved = 2147483647; + break; + } + return message; + }; + + /** + * Creates a plain object from a FeatureSupport message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {google.protobuf.FieldOptions.FeatureSupport} message FeatureSupport + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSupport.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.editionIntroduced = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.editionDeprecated = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.deprecationWarning = ""; + object.editionRemoved = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.editionIntroduced != null && message.hasOwnProperty("editionIntroduced")) + object.editionIntroduced = options.enums === String ? $root.google.protobuf.Edition[message.editionIntroduced] === undefined ? message.editionIntroduced : $root.google.protobuf.Edition[message.editionIntroduced] : message.editionIntroduced; + if (message.editionDeprecated != null && message.hasOwnProperty("editionDeprecated")) + object.editionDeprecated = options.enums === String ? $root.google.protobuf.Edition[message.editionDeprecated] === undefined ? message.editionDeprecated : $root.google.protobuf.Edition[message.editionDeprecated] : message.editionDeprecated; + if (message.deprecationWarning != null && message.hasOwnProperty("deprecationWarning")) + object.deprecationWarning = message.deprecationWarning; + if (message.editionRemoved != null && message.hasOwnProperty("editionRemoved")) + object.editionRemoved = options.enums === String ? $root.google.protobuf.Edition[message.editionRemoved] === undefined ? message.editionRemoved : $root.google.protobuf.Edition[message.editionRemoved] : message.editionRemoved; + return object; + }; + + /** + * Converts this FeatureSupport to JSON. + * @function toJSON + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @instance + * @returns {Object.} JSON object + */ + FeatureSupport.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSupport + * @function getTypeUrl + * @memberof google.protobuf.FieldOptions.FeatureSupport + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSupport.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FieldOptions.FeatureSupport"; + }; + + return FeatureSupport; + })(); + + return FieldOptions; + })(); + + protobuf.OneofOptions = (function() { + + /** + * Properties of an OneofOptions. + * @memberof google.protobuf + * @interface IOneofOptions + * @property {google.protobuf.IFeatureSet|null} [features] OneofOptions features + * @property {Array.|null} [uninterpretedOption] OneofOptions uninterpretedOption + */ + + /** + * Constructs a new OneofOptions. + * @memberof google.protobuf + * @classdesc Represents an OneofOptions. + * @implements IOneofOptions + * @constructor + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + */ + function OneofOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OneofOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.features = null; + + /** + * OneofOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.OneofOptions + * @instance + */ + OneofOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates a new OneofOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions=} [properties] Properties to set + * @returns {google.protobuf.OneofOptions} OneofOptions instance + */ + OneofOptions.create = function create(properties) { + return new OneofOptions(properties); + }; + + /** + * Encodes the specified OneofOptions message. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified OneofOptions message, length delimited. Does not implicitly {@link google.protobuf.OneofOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.IOneofOptions} message OneofOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OneofOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OneofOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.OneofOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OneofOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.OneofOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.OneofOptions} OneofOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OneofOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OneofOptions message. + * @function verify + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OneofOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * Creates an OneofOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.OneofOptions} OneofOptions + */ + OneofOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.OneofOptions) + return object; + var message = new $root.google.protobuf.OneofOptions(); + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.OneofOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.OneofOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an OneofOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.OneofOptions + * @static + * @param {google.protobuf.OneofOptions} message OneofOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OneofOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) + object.features = null; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this OneofOptions to JSON. + * @function toJSON + * @memberof google.protobuf.OneofOptions + * @instance + * @returns {Object.} JSON object + */ + OneofOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OneofOptions + * @function getTypeUrl + * @memberof google.protobuf.OneofOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OneofOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.OneofOptions"; + }; + + return OneofOptions; + })(); + + protobuf.EnumOptions = (function() { + + /** + * Properties of an EnumOptions. + * @memberof google.protobuf + * @interface IEnumOptions + * @property {boolean|null} [allowAlias] EnumOptions allowAlias + * @property {boolean|null} [deprecated] EnumOptions deprecated + * @property {boolean|null} [deprecatedLegacyJsonFieldConflicts] EnumOptions deprecatedLegacyJsonFieldConflicts + * @property {google.protobuf.IFeatureSet|null} [features] EnumOptions features + * @property {Array.|null} [uninterpretedOption] EnumOptions uninterpretedOption + */ + + /** + * Constructs a new EnumOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumOptions. + * @implements IEnumOptions + * @constructor + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + */ + function EnumOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumOptions allowAlias. + * @member {boolean} allowAlias + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.allowAlias = false; + + /** + * EnumOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecated = false; + + /** + * EnumOptions deprecatedLegacyJsonFieldConflicts. + * @member {boolean} deprecatedLegacyJsonFieldConflicts + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.deprecatedLegacyJsonFieldConflicts = false; + + /** + * EnumOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.features = null; + + /** + * EnumOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumOptions + * @instance + */ + EnumOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates a new EnumOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumOptions} EnumOptions instance + */ + EnumOptions.create = function create(properties) { + return new EnumOptions(properties); + }; + + /** + * Encodes the specified EnumOptions message. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.allowAlias != null && Object.hasOwnProperty.call(message, "allowAlias")) + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.allowAlias); + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.deprecated); + if (message.deprecatedLegacyJsonFieldConflicts != null && Object.hasOwnProperty.call(message, "deprecatedLegacyJsonFieldConflicts")) + writer.uint32(/* id 6, wireType 0 =*/48).bool(message.deprecatedLegacyJsonFieldConflicts); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 7, wireType 2 =*/58).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EnumOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.IEnumOptions} message EnumOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + message.allowAlias = reader.bool(); + break; + } + case 3: { + message.deprecated = reader.bool(); + break; + } + case 6: { + message.deprecatedLegacyJsonFieldConflicts = reader.bool(); + break; + } + case 7: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumOptions} EnumOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumOptions message. + * @function verify + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + if (typeof message.allowAlias !== "boolean") + return "allowAlias: boolean expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.deprecatedLegacyJsonFieldConflicts != null && message.hasOwnProperty("deprecatedLegacyJsonFieldConflicts")) + if (typeof message.deprecatedLegacyJsonFieldConflicts !== "boolean") + return "deprecatedLegacyJsonFieldConflicts: boolean expected"; + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * Creates an EnumOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumOptions} EnumOptions + */ + EnumOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumOptions) + return object; + var message = new $root.google.protobuf.EnumOptions(); + if (object.allowAlias != null) + message.allowAlias = Boolean(object.allowAlias); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.deprecatedLegacyJsonFieldConflicts != null) + message.deprecatedLegacyJsonFieldConflicts = Boolean(object.deprecatedLegacyJsonFieldConflicts); + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.EnumOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumOptions + * @static + * @param {google.protobuf.EnumOptions} message EnumOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.allowAlias = false; + object.deprecated = false; + object.deprecatedLegacyJsonFieldConflicts = false; + object.features = null; + } + if (message.allowAlias != null && message.hasOwnProperty("allowAlias")) + object.allowAlias = message.allowAlias; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.deprecatedLegacyJsonFieldConflicts != null && message.hasOwnProperty("deprecatedLegacyJsonFieldConflicts")) + object.deprecatedLegacyJsonFieldConflicts = message.deprecatedLegacyJsonFieldConflicts; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this EnumOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumOptions + * @instance + * @returns {Object.} JSON object + */ + EnumOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EnumOptions + * @function getTypeUrl + * @memberof google.protobuf.EnumOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumOptions"; + }; + + return EnumOptions; + })(); + + protobuf.EnumValueOptions = (function() { + + /** + * Properties of an EnumValueOptions. + * @memberof google.protobuf + * @interface IEnumValueOptions + * @property {boolean|null} [deprecated] EnumValueOptions deprecated + * @property {google.protobuf.IFeatureSet|null} [features] EnumValueOptions features + * @property {boolean|null} [debugRedact] EnumValueOptions debugRedact + * @property {google.protobuf.FieldOptions.IFeatureSupport|null} [featureSupport] EnumValueOptions featureSupport + * @property {Array.|null} [uninterpretedOption] EnumValueOptions uninterpretedOption + */ + + /** + * Constructs a new EnumValueOptions. + * @memberof google.protobuf + * @classdesc Represents an EnumValueOptions. + * @implements IEnumValueOptions + * @constructor + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + */ + function EnumValueOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * EnumValueOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.deprecated = false; + + /** + * EnumValueOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.features = null; + + /** + * EnumValueOptions debugRedact. + * @member {boolean} debugRedact + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.debugRedact = false; + + /** + * EnumValueOptions featureSupport. + * @member {google.protobuf.FieldOptions.IFeatureSupport|null|undefined} featureSupport + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.featureSupport = null; + + /** + * EnumValueOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.EnumValueOptions + * @instance + */ + EnumValueOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * Creates a new EnumValueOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions=} [properties] Properties to set + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions instance + */ + EnumValueOptions.create = function create(properties) { + return new EnumValueOptions(properties); + }; + + /** + * Encodes the specified EnumValueOptions message. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.deprecated); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.debugRedact != null && Object.hasOwnProperty.call(message, "debugRedact")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.debugRedact); + if (message.featureSupport != null && Object.hasOwnProperty.call(message, "featureSupport")) + $root.google.protobuf.FieldOptions.FeatureSupport.encode(message.featureSupport, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified EnumValueOptions message, length delimited. Does not implicitly {@link google.protobuf.EnumValueOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.IEnumValueOptions} message EnumValueOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + EnumValueOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.EnumValueOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.deprecated = reader.bool(); + break; + } + case 2: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 3: { + message.debugRedact = reader.bool(); + break; + } + case 4: { + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.decode(reader, reader.uint32()); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an EnumValueOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + EnumValueOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an EnumValueOptions message. + * @function verify + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + EnumValueOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) + if (typeof message.debugRedact !== "boolean") + return "debugRedact: boolean expected"; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) { + var error = $root.google.protobuf.FieldOptions.FeatureSupport.verify(message.featureSupport); + if (error) + return "featureSupport." + error; + } + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + return null; + }; + + /** + * Creates an EnumValueOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.EnumValueOptions} EnumValueOptions + */ + EnumValueOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.EnumValueOptions) + return object; + var message = new $root.google.protobuf.EnumValueOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.debugRedact != null) + message.debugRedact = Boolean(object.debugRedact); + if (object.featureSupport != null) { + if (typeof object.featureSupport !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.featureSupport: object expected"); + message.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.fromObject(object.featureSupport); + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.EnumValueOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + return message; + }; + + /** + * Creates a plain object from an EnumValueOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {google.protobuf.EnumValueOptions} message EnumValueOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + EnumValueOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.deprecated = false; + object.features = null; + object.debugRedact = false; + object.featureSupport = null; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.debugRedact != null && message.hasOwnProperty("debugRedact")) + object.debugRedact = message.debugRedact; + if (message.featureSupport != null && message.hasOwnProperty("featureSupport")) + object.featureSupport = $root.google.protobuf.FieldOptions.FeatureSupport.toObject(message.featureSupport, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + return object; + }; + + /** + * Converts this EnumValueOptions to JSON. + * @function toJSON + * @memberof google.protobuf.EnumValueOptions + * @instance + * @returns {Object.} JSON object + */ + EnumValueOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for EnumValueOptions + * @function getTypeUrl + * @memberof google.protobuf.EnumValueOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + EnumValueOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.EnumValueOptions"; + }; + + return EnumValueOptions; + })(); + + protobuf.ServiceOptions = (function() { + + /** + * Properties of a ServiceOptions. + * @memberof google.protobuf + * @interface IServiceOptions + * @property {google.protobuf.IFeatureSet|null} [features] ServiceOptions features + * @property {boolean|null} [deprecated] ServiceOptions deprecated + * @property {Array.|null} [uninterpretedOption] ServiceOptions uninterpretedOption + * @property {string|null} [".google.api.defaultHost"] ServiceOptions .google.api.defaultHost + * @property {string|null} [".google.api.oauthScopes"] ServiceOptions .google.api.oauthScopes + * @property {string|null} [".google.api.apiVersion"] ServiceOptions .google.api.apiVersion + */ + + /** + * Constructs a new ServiceOptions. + * @memberof google.protobuf + * @classdesc Represents a ServiceOptions. + * @implements IServiceOptions + * @constructor + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + */ + function ServiceOptions(properties) { + this.uninterpretedOption = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ServiceOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.features = null; + + /** + * ServiceOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.deprecated = false; + + /** + * ServiceOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * ServiceOptions .google.api.defaultHost. + * @member {string} .google.api.defaultHost + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.defaultHost"] = ""; + + /** + * ServiceOptions .google.api.oauthScopes. + * @member {string} .google.api.oauthScopes + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.oauthScopes"] = ""; + + /** + * ServiceOptions .google.api.apiVersion. + * @member {string} .google.api.apiVersion + * @memberof google.protobuf.ServiceOptions + * @instance + */ + ServiceOptions.prototype[".google.api.apiVersion"] = ""; + + /** + * Creates a new ServiceOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions=} [properties] Properties to set + * @returns {google.protobuf.ServiceOptions} ServiceOptions instance + */ + ServiceOptions.create = function create(properties) { + return new ServiceOptions(properties); + }; + + /** + * Encodes the specified ServiceOptions message. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) + writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 34, wireType 2 =*/274).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + if (message[".google.api.defaultHost"] != null && Object.hasOwnProperty.call(message, ".google.api.defaultHost")) + writer.uint32(/* id 1049, wireType 2 =*/8394).string(message[".google.api.defaultHost"]); + if (message[".google.api.oauthScopes"] != null && Object.hasOwnProperty.call(message, ".google.api.oauthScopes")) + writer.uint32(/* id 1050, wireType 2 =*/8402).string(message[".google.api.oauthScopes"]); + if (message[".google.api.apiVersion"] != null && Object.hasOwnProperty.call(message, ".google.api.apiVersion")) + writer.uint32(/* id 525000001, wireType 2 =*/4200000010).string(message[".google.api.apiVersion"]); + return writer; + }; + + /** + * Encodes the specified ServiceOptions message, length delimited. Does not implicitly {@link google.protobuf.ServiceOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.IServiceOptions} message ServiceOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ServiceOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ServiceOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 34: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 33: { + message.deprecated = reader.bool(); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 1049: { + message[".google.api.defaultHost"] = reader.string(); + break; + } + case 1050: { + message[".google.api.oauthScopes"] = reader.string(); + break; + } + case 525000001: { + message[".google.api.apiVersion"] = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ServiceOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ServiceOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ServiceOptions} ServiceOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ServiceOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ServiceOptions message. + * @function verify + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ServiceOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + if (message[".google.api.defaultHost"] != null && message.hasOwnProperty(".google.api.defaultHost")) + if (!$util.isString(message[".google.api.defaultHost"])) + return ".google.api.defaultHost: string expected"; + if (message[".google.api.oauthScopes"] != null && message.hasOwnProperty(".google.api.oauthScopes")) + if (!$util.isString(message[".google.api.oauthScopes"])) + return ".google.api.oauthScopes: string expected"; + if (message[".google.api.apiVersion"] != null && message.hasOwnProperty(".google.api.apiVersion")) + if (!$util.isString(message[".google.api.apiVersion"])) + return ".google.api.apiVersion: string expected"; + return null; + }; + + /** + * Creates a ServiceOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ServiceOptions} ServiceOptions + */ + ServiceOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ServiceOptions) + return object; + var message = new $root.google.protobuf.ServiceOptions(); + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.ServiceOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.ServiceOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.defaultHost"] != null) + message[".google.api.defaultHost"] = String(object[".google.api.defaultHost"]); + if (object[".google.api.oauthScopes"] != null) + message[".google.api.oauthScopes"] = String(object[".google.api.oauthScopes"]); + if (object[".google.api.apiVersion"] != null) + message[".google.api.apiVersion"] = String(object[".google.api.apiVersion"]); + return message; + }; + + /** + * Creates a plain object from a ServiceOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ServiceOptions + * @static + * @param {google.protobuf.ServiceOptions} message ServiceOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ServiceOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.uninterpretedOption = []; + if (options.defaults) { + object.deprecated = false; + object.features = null; + object[".google.api.defaultHost"] = ""; + object[".google.api.oauthScopes"] = ""; + object[".google.api.apiVersion"] = ""; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.api.defaultHost"] != null && message.hasOwnProperty(".google.api.defaultHost")) + object[".google.api.defaultHost"] = message[".google.api.defaultHost"]; + if (message[".google.api.oauthScopes"] != null && message.hasOwnProperty(".google.api.oauthScopes")) + object[".google.api.oauthScopes"] = message[".google.api.oauthScopes"]; + if (message[".google.api.apiVersion"] != null && message.hasOwnProperty(".google.api.apiVersion")) + object[".google.api.apiVersion"] = message[".google.api.apiVersion"]; + return object; + }; + + /** + * Converts this ServiceOptions to JSON. + * @function toJSON + * @memberof google.protobuf.ServiceOptions + * @instance + * @returns {Object.} JSON object + */ + ServiceOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ServiceOptions + * @function getTypeUrl + * @memberof google.protobuf.ServiceOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ServiceOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ServiceOptions"; + }; + + return ServiceOptions; + })(); + + protobuf.MethodOptions = (function() { + + /** + * Properties of a MethodOptions. + * @memberof google.protobuf + * @interface IMethodOptions + * @property {boolean|null} [deprecated] MethodOptions deprecated + * @property {google.protobuf.MethodOptions.IdempotencyLevel|null} [idempotencyLevel] MethodOptions idempotencyLevel + * @property {google.protobuf.IFeatureSet|null} [features] MethodOptions features + * @property {Array.|null} [uninterpretedOption] MethodOptions uninterpretedOption + * @property {google.api.IHttpRule|null} [".google.api.http"] MethodOptions .google.api.http + * @property {Array.|null} [".google.api.methodSignature"] MethodOptions .google.api.methodSignature + * @property {google.longrunning.IOperationInfo|null} [".google.longrunning.operationInfo"] MethodOptions .google.longrunning.operationInfo + * @property {google.api.IRoutingRule|null} [".google.api.routing"] MethodOptions .google.api.routing + */ + + /** + * Constructs a new MethodOptions. + * @memberof google.protobuf + * @classdesc Represents a MethodOptions. + * @implements IMethodOptions + * @constructor + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + */ + function MethodOptions(properties) { + this.uninterpretedOption = []; + this[".google.api.methodSignature"] = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * MethodOptions deprecated. + * @member {boolean} deprecated + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.deprecated = false; + + /** + * MethodOptions idempotencyLevel. + * @member {google.protobuf.MethodOptions.IdempotencyLevel} idempotencyLevel + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.idempotencyLevel = 0; + + /** + * MethodOptions features. + * @member {google.protobuf.IFeatureSet|null|undefined} features + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.features = null; + + /** + * MethodOptions uninterpretedOption. + * @member {Array.} uninterpretedOption + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype.uninterpretedOption = $util.emptyArray; + + /** + * MethodOptions .google.api.http. + * @member {google.api.IHttpRule|null|undefined} .google.api.http + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.http"] = null; + + /** + * MethodOptions .google.api.methodSignature. + * @member {Array.} .google.api.methodSignature + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.methodSignature"] = $util.emptyArray; + + /** + * MethodOptions .google.longrunning.operationInfo. + * @member {google.longrunning.IOperationInfo|null|undefined} .google.longrunning.operationInfo + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.longrunning.operationInfo"] = null; + + /** + * MethodOptions .google.api.routing. + * @member {google.api.IRoutingRule|null|undefined} .google.api.routing + * @memberof google.protobuf.MethodOptions + * @instance + */ + MethodOptions.prototype[".google.api.routing"] = null; + + /** + * Creates a new MethodOptions instance using the specified properties. + * @function create + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions=} [properties] Properties to set + * @returns {google.protobuf.MethodOptions} MethodOptions instance + */ + MethodOptions.create = function create(properties) { + return new MethodOptions(properties); + }; + + /** + * Encodes the specified MethodOptions message. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encode + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.deprecated != null && Object.hasOwnProperty.call(message, "deprecated")) + writer.uint32(/* id 33, wireType 0 =*/264).bool(message.deprecated); + if (message.idempotencyLevel != null && Object.hasOwnProperty.call(message, "idempotencyLevel")) + writer.uint32(/* id 34, wireType 0 =*/272).int32(message.idempotencyLevel); + if (message.features != null && Object.hasOwnProperty.call(message, "features")) + $root.google.protobuf.FeatureSet.encode(message.features, writer.uint32(/* id 35, wireType 2 =*/282).fork()).ldelim(); + if (message.uninterpretedOption != null && message.uninterpretedOption.length) + for (var i = 0; i < message.uninterpretedOption.length; ++i) + $root.google.protobuf.UninterpretedOption.encode(message.uninterpretedOption[i], writer.uint32(/* id 999, wireType 2 =*/7994).fork()).ldelim(); + if (message[".google.longrunning.operationInfo"] != null && Object.hasOwnProperty.call(message, ".google.longrunning.operationInfo")) + $root.google.longrunning.OperationInfo.encode(message[".google.longrunning.operationInfo"], writer.uint32(/* id 1049, wireType 2 =*/8394).fork()).ldelim(); + if (message[".google.api.methodSignature"] != null && message[".google.api.methodSignature"].length) + for (var i = 0; i < message[".google.api.methodSignature"].length; ++i) + writer.uint32(/* id 1051, wireType 2 =*/8410).string(message[".google.api.methodSignature"][i]); + if (message[".google.api.http"] != null && Object.hasOwnProperty.call(message, ".google.api.http")) + $root.google.api.HttpRule.encode(message[".google.api.http"], writer.uint32(/* id 72295728, wireType 2 =*/578365826).fork()).ldelim(); + if (message[".google.api.routing"] != null && Object.hasOwnProperty.call(message, ".google.api.routing")) + $root.google.api.RoutingRule.encode(message[".google.api.routing"], writer.uint32(/* id 72295729, wireType 2 =*/578365834).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified MethodOptions message, length delimited. Does not implicitly {@link google.protobuf.MethodOptions.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.IMethodOptions} message MethodOptions message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + MethodOptions.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a MethodOptions message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.MethodOptions(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 33: { + message.deprecated = reader.bool(); + break; + } + case 34: { + message.idempotencyLevel = reader.int32(); + break; + } + case 35: { + message.features = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 999: { + if (!(message.uninterpretedOption && message.uninterpretedOption.length)) + message.uninterpretedOption = []; + message.uninterpretedOption.push($root.google.protobuf.UninterpretedOption.decode(reader, reader.uint32())); + break; + } + case 72295728: { + message[".google.api.http"] = $root.google.api.HttpRule.decode(reader, reader.uint32()); + break; + } + case 1051: { + if (!(message[".google.api.methodSignature"] && message[".google.api.methodSignature"].length)) + message[".google.api.methodSignature"] = []; + message[".google.api.methodSignature"].push(reader.string()); + break; + } + case 1049: { + message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.decode(reader, reader.uint32()); + break; + } + case 72295729: { + message[".google.api.routing"] = $root.google.api.RoutingRule.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a MethodOptions message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.MethodOptions + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.MethodOptions} MethodOptions + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + MethodOptions.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a MethodOptions message. + * @function verify + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + MethodOptions.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + if (typeof message.deprecated !== "boolean") + return "deprecated: boolean expected"; + if (message.idempotencyLevel != null && message.hasOwnProperty("idempotencyLevel")) + switch (message.idempotencyLevel) { + default: + return "idempotencyLevel: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.features != null && message.hasOwnProperty("features")) { + var error = $root.google.protobuf.FeatureSet.verify(message.features); + if (error) + return "features." + error; + } + if (message.uninterpretedOption != null && message.hasOwnProperty("uninterpretedOption")) { + if (!Array.isArray(message.uninterpretedOption)) + return "uninterpretedOption: array expected"; + for (var i = 0; i < message.uninterpretedOption.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.verify(message.uninterpretedOption[i]); + if (error) + return "uninterpretedOption." + error; + } + } + if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) { + var error = $root.google.api.HttpRule.verify(message[".google.api.http"]); + if (error) + return ".google.api.http." + error; + } + if (message[".google.api.methodSignature"] != null && message.hasOwnProperty(".google.api.methodSignature")) { + if (!Array.isArray(message[".google.api.methodSignature"])) + return ".google.api.methodSignature: array expected"; + for (var i = 0; i < message[".google.api.methodSignature"].length; ++i) + if (!$util.isString(message[".google.api.methodSignature"][i])) + return ".google.api.methodSignature: string[] expected"; + } + if (message[".google.longrunning.operationInfo"] != null && message.hasOwnProperty(".google.longrunning.operationInfo")) { + var error = $root.google.longrunning.OperationInfo.verify(message[".google.longrunning.operationInfo"]); + if (error) + return ".google.longrunning.operationInfo." + error; + } + if (message[".google.api.routing"] != null && message.hasOwnProperty(".google.api.routing")) { + var error = $root.google.api.RoutingRule.verify(message[".google.api.routing"]); + if (error) + return ".google.api.routing." + error; + } + return null; + }; + + /** + * Creates a MethodOptions message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.MethodOptions} MethodOptions + */ + MethodOptions.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.MethodOptions) + return object; + var message = new $root.google.protobuf.MethodOptions(); + if (object.deprecated != null) + message.deprecated = Boolean(object.deprecated); + switch (object.idempotencyLevel) { + default: + if (typeof object.idempotencyLevel === "number") { + message.idempotencyLevel = object.idempotencyLevel; + break; + } + break; + case "IDEMPOTENCY_UNKNOWN": + case 0: + message.idempotencyLevel = 0; + break; + case "NO_SIDE_EFFECTS": + case 1: + message.idempotencyLevel = 1; + break; + case "IDEMPOTENT": + case 2: + message.idempotencyLevel = 2; + break; + } + if (object.features != null) { + if (typeof object.features !== "object") + throw TypeError(".google.protobuf.MethodOptions.features: object expected"); + message.features = $root.google.protobuf.FeatureSet.fromObject(object.features); + } + if (object.uninterpretedOption) { + if (!Array.isArray(object.uninterpretedOption)) + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: array expected"); + message.uninterpretedOption = []; + for (var i = 0; i < object.uninterpretedOption.length; ++i) { + if (typeof object.uninterpretedOption[i] !== "object") + throw TypeError(".google.protobuf.MethodOptions.uninterpretedOption: object expected"); + message.uninterpretedOption[i] = $root.google.protobuf.UninterpretedOption.fromObject(object.uninterpretedOption[i]); + } + } + if (object[".google.api.http"] != null) { + if (typeof object[".google.api.http"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.api.http: object expected"); + message[".google.api.http"] = $root.google.api.HttpRule.fromObject(object[".google.api.http"]); + } + if (object[".google.api.methodSignature"]) { + if (!Array.isArray(object[".google.api.methodSignature"])) + throw TypeError(".google.protobuf.MethodOptions..google.api.methodSignature: array expected"); + message[".google.api.methodSignature"] = []; + for (var i = 0; i < object[".google.api.methodSignature"].length; ++i) + message[".google.api.methodSignature"][i] = String(object[".google.api.methodSignature"][i]); + } + if (object[".google.longrunning.operationInfo"] != null) { + if (typeof object[".google.longrunning.operationInfo"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.longrunning.operationInfo: object expected"); + message[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.fromObject(object[".google.longrunning.operationInfo"]); + } + if (object[".google.api.routing"] != null) { + if (typeof object[".google.api.routing"] !== "object") + throw TypeError(".google.protobuf.MethodOptions..google.api.routing: object expected"); + message[".google.api.routing"] = $root.google.api.RoutingRule.fromObject(object[".google.api.routing"]); + } + return message; + }; + + /** + * Creates a plain object from a MethodOptions message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.MethodOptions + * @static + * @param {google.protobuf.MethodOptions} message MethodOptions + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + MethodOptions.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.uninterpretedOption = []; + object[".google.api.methodSignature"] = []; + } + if (options.defaults) { + object.deprecated = false; + object.idempotencyLevel = options.enums === String ? "IDEMPOTENCY_UNKNOWN" : 0; + object.features = null; + object[".google.longrunning.operationInfo"] = null; + object[".google.api.http"] = null; + object[".google.api.routing"] = null; + } + if (message.deprecated != null && message.hasOwnProperty("deprecated")) + object.deprecated = message.deprecated; + if (message.idempotencyLevel != null && message.hasOwnProperty("idempotencyLevel")) + object.idempotencyLevel = options.enums === String ? $root.google.protobuf.MethodOptions.IdempotencyLevel[message.idempotencyLevel] === undefined ? message.idempotencyLevel : $root.google.protobuf.MethodOptions.IdempotencyLevel[message.idempotencyLevel] : message.idempotencyLevel; + if (message.features != null && message.hasOwnProperty("features")) + object.features = $root.google.protobuf.FeatureSet.toObject(message.features, options); + if (message.uninterpretedOption && message.uninterpretedOption.length) { + object.uninterpretedOption = []; + for (var j = 0; j < message.uninterpretedOption.length; ++j) + object.uninterpretedOption[j] = $root.google.protobuf.UninterpretedOption.toObject(message.uninterpretedOption[j], options); + } + if (message[".google.longrunning.operationInfo"] != null && message.hasOwnProperty(".google.longrunning.operationInfo")) + object[".google.longrunning.operationInfo"] = $root.google.longrunning.OperationInfo.toObject(message[".google.longrunning.operationInfo"], options); + if (message[".google.api.methodSignature"] && message[".google.api.methodSignature"].length) { + object[".google.api.methodSignature"] = []; + for (var j = 0; j < message[".google.api.methodSignature"].length; ++j) + object[".google.api.methodSignature"][j] = message[".google.api.methodSignature"][j]; + } + if (message[".google.api.http"] != null && message.hasOwnProperty(".google.api.http")) + object[".google.api.http"] = $root.google.api.HttpRule.toObject(message[".google.api.http"], options); + if (message[".google.api.routing"] != null && message.hasOwnProperty(".google.api.routing")) + object[".google.api.routing"] = $root.google.api.RoutingRule.toObject(message[".google.api.routing"], options); + return object; + }; + + /** + * Converts this MethodOptions to JSON. + * @function toJSON + * @memberof google.protobuf.MethodOptions + * @instance + * @returns {Object.} JSON object + */ + MethodOptions.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for MethodOptions + * @function getTypeUrl + * @memberof google.protobuf.MethodOptions + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + MethodOptions.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.MethodOptions"; + }; + + /** + * IdempotencyLevel enum. + * @name google.protobuf.MethodOptions.IdempotencyLevel + * @enum {number} + * @property {number} IDEMPOTENCY_UNKNOWN=0 IDEMPOTENCY_UNKNOWN value + * @property {number} NO_SIDE_EFFECTS=1 NO_SIDE_EFFECTS value + * @property {number} IDEMPOTENT=2 IDEMPOTENT value + */ + MethodOptions.IdempotencyLevel = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "IDEMPOTENCY_UNKNOWN"] = 0; + values[valuesById[1] = "NO_SIDE_EFFECTS"] = 1; + values[valuesById[2] = "IDEMPOTENT"] = 2; + return values; + })(); + + return MethodOptions; + })(); + + protobuf.UninterpretedOption = (function() { + + /** + * Properties of an UninterpretedOption. + * @memberof google.protobuf + * @interface IUninterpretedOption + * @property {Array.|null} [name] UninterpretedOption name + * @property {string|null} [identifierValue] UninterpretedOption identifierValue + * @property {number|Long|null} [positiveIntValue] UninterpretedOption positiveIntValue + * @property {number|Long|null} [negativeIntValue] UninterpretedOption negativeIntValue + * @property {number|null} [doubleValue] UninterpretedOption doubleValue + * @property {Uint8Array|null} [stringValue] UninterpretedOption stringValue + * @property {string|null} [aggregateValue] UninterpretedOption aggregateValue + */ + + /** + * Constructs a new UninterpretedOption. + * @memberof google.protobuf + * @classdesc Represents an UninterpretedOption. + * @implements IUninterpretedOption + * @constructor + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + */ + function UninterpretedOption(properties) { + this.name = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UninterpretedOption name. + * @member {Array.} name + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.name = $util.emptyArray; + + /** + * UninterpretedOption identifierValue. + * @member {string} identifierValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.identifierValue = ""; + + /** + * UninterpretedOption positiveIntValue. + * @member {number|Long} positiveIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.positiveIntValue = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * UninterpretedOption negativeIntValue. + * @member {number|Long} negativeIntValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.negativeIntValue = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * UninterpretedOption doubleValue. + * @member {number} doubleValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.doubleValue = 0; + + /** + * UninterpretedOption stringValue. + * @member {Uint8Array} stringValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.stringValue = $util.newBuffer([]); + + /** + * UninterpretedOption aggregateValue. + * @member {string} aggregateValue + * @memberof google.protobuf.UninterpretedOption + * @instance + */ + UninterpretedOption.prototype.aggregateValue = ""; + + /** + * Creates a new UninterpretedOption instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption instance + */ + UninterpretedOption.create = function create(properties) { + return new UninterpretedOption(properties); + }; + + /** + * Encodes the specified UninterpretedOption message. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && message.name.length) + for (var i = 0; i < message.name.length; ++i) + $root.google.protobuf.UninterpretedOption.NamePart.encode(message.name[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.identifierValue != null && Object.hasOwnProperty.call(message, "identifierValue")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.identifierValue); + if (message.positiveIntValue != null && Object.hasOwnProperty.call(message, "positiveIntValue")) + writer.uint32(/* id 4, wireType 0 =*/32).uint64(message.positiveIntValue); + if (message.negativeIntValue != null && Object.hasOwnProperty.call(message, "negativeIntValue")) + writer.uint32(/* id 5, wireType 0 =*/40).int64(message.negativeIntValue); + if (message.doubleValue != null && Object.hasOwnProperty.call(message, "doubleValue")) + writer.uint32(/* id 6, wireType 1 =*/49).double(message.doubleValue); + if (message.stringValue != null && Object.hasOwnProperty.call(message, "stringValue")) + writer.uint32(/* id 7, wireType 2 =*/58).bytes(message.stringValue); + if (message.aggregateValue != null && Object.hasOwnProperty.call(message, "aggregateValue")) + writer.uint32(/* id 8, wireType 2 =*/66).string(message.aggregateValue); + return writer; + }; + + /** + * Encodes the specified UninterpretedOption message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.IUninterpretedOption} message UninterpretedOption message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UninterpretedOption.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UninterpretedOption(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: { + if (!(message.name && message.name.length)) + message.name = []; + message.name.push($root.google.protobuf.UninterpretedOption.NamePart.decode(reader, reader.uint32())); + break; + } + case 3: { + message.identifierValue = reader.string(); + break; + } + case 4: { + message.positiveIntValue = reader.uint64(); + break; + } + case 5: { + message.negativeIntValue = reader.int64(); + break; + } + case 6: { + message.doubleValue = reader.double(); + break; + } + case 7: { + message.stringValue = reader.bytes(); + break; + } + case 8: { + message.aggregateValue = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UninterpretedOption message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UninterpretedOption.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UninterpretedOption message. + * @function verify + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UninterpretedOption.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) { + if (!Array.isArray(message.name)) + return "name: array expected"; + for (var i = 0; i < message.name.length; ++i) { + var error = $root.google.protobuf.UninterpretedOption.NamePart.verify(message.name[i]); + if (error) + return "name." + error; + } + } + if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + if (!$util.isString(message.identifierValue)) + return "identifierValue: string expected"; + if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (!$util.isInteger(message.positiveIntValue) && !(message.positiveIntValue && $util.isInteger(message.positiveIntValue.low) && $util.isInteger(message.positiveIntValue.high))) + return "positiveIntValue: integer|Long expected"; + if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (!$util.isInteger(message.negativeIntValue) && !(message.negativeIntValue && $util.isInteger(message.negativeIntValue.low) && $util.isInteger(message.negativeIntValue.high))) + return "negativeIntValue: integer|Long expected"; + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + if (typeof message.doubleValue !== "number") + return "doubleValue: number expected"; + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + if (!(message.stringValue && typeof message.stringValue.length === "number" || $util.isString(message.stringValue))) + return "stringValue: buffer expected"; + if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + if (!$util.isString(message.aggregateValue)) + return "aggregateValue: string expected"; + return null; + }; + + /** + * Creates an UninterpretedOption message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption} UninterpretedOption + */ + UninterpretedOption.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption) + return object; + var message = new $root.google.protobuf.UninterpretedOption(); + if (object.name) { + if (!Array.isArray(object.name)) + throw TypeError(".google.protobuf.UninterpretedOption.name: array expected"); + message.name = []; + for (var i = 0; i < object.name.length; ++i) { + if (typeof object.name[i] !== "object") + throw TypeError(".google.protobuf.UninterpretedOption.name: object expected"); + message.name[i] = $root.google.protobuf.UninterpretedOption.NamePart.fromObject(object.name[i]); + } + } + if (object.identifierValue != null) + message.identifierValue = String(object.identifierValue); + if (object.positiveIntValue != null) + if ($util.Long) + (message.positiveIntValue = $util.Long.fromValue(object.positiveIntValue)).unsigned = true; + else if (typeof object.positiveIntValue === "string") + message.positiveIntValue = parseInt(object.positiveIntValue, 10); + else if (typeof object.positiveIntValue === "number") + message.positiveIntValue = object.positiveIntValue; + else if (typeof object.positiveIntValue === "object") + message.positiveIntValue = new $util.LongBits(object.positiveIntValue.low >>> 0, object.positiveIntValue.high >>> 0).toNumber(true); + if (object.negativeIntValue != null) + if ($util.Long) + (message.negativeIntValue = $util.Long.fromValue(object.negativeIntValue)).unsigned = false; + else if (typeof object.negativeIntValue === "string") + message.negativeIntValue = parseInt(object.negativeIntValue, 10); + else if (typeof object.negativeIntValue === "number") + message.negativeIntValue = object.negativeIntValue; + else if (typeof object.negativeIntValue === "object") + message.negativeIntValue = new $util.LongBits(object.negativeIntValue.low >>> 0, object.negativeIntValue.high >>> 0).toNumber(); + if (object.doubleValue != null) + message.doubleValue = Number(object.doubleValue); + if (object.stringValue != null) + if (typeof object.stringValue === "string") + $util.base64.decode(object.stringValue, message.stringValue = $util.newBuffer($util.base64.length(object.stringValue)), 0); + else if (object.stringValue.length >= 0) + message.stringValue = object.stringValue; + if (object.aggregateValue != null) + message.aggregateValue = String(object.aggregateValue); + return message; + }; + + /** + * Creates a plain object from an UninterpretedOption message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {google.protobuf.UninterpretedOption} message UninterpretedOption + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UninterpretedOption.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.name = []; + if (options.defaults) { + object.identifierValue = ""; + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.positiveIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.positiveIntValue = options.longs === String ? "0" : 0; + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.negativeIntValue = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.negativeIntValue = options.longs === String ? "0" : 0; + object.doubleValue = 0; + if (options.bytes === String) + object.stringValue = ""; + else { + object.stringValue = []; + if (options.bytes !== Array) + object.stringValue = $util.newBuffer(object.stringValue); + } + object.aggregateValue = ""; + } + if (message.name && message.name.length) { + object.name = []; + for (var j = 0; j < message.name.length; ++j) + object.name[j] = $root.google.protobuf.UninterpretedOption.NamePart.toObject(message.name[j], options); + } + if (message.identifierValue != null && message.hasOwnProperty("identifierValue")) + object.identifierValue = message.identifierValue; + if (message.positiveIntValue != null && message.hasOwnProperty("positiveIntValue")) + if (typeof message.positiveIntValue === "number") + object.positiveIntValue = options.longs === String ? String(message.positiveIntValue) : message.positiveIntValue; + else + object.positiveIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.positiveIntValue) : options.longs === Number ? new $util.LongBits(message.positiveIntValue.low >>> 0, message.positiveIntValue.high >>> 0).toNumber(true) : message.positiveIntValue; + if (message.negativeIntValue != null && message.hasOwnProperty("negativeIntValue")) + if (typeof message.negativeIntValue === "number") + object.negativeIntValue = options.longs === String ? String(message.negativeIntValue) : message.negativeIntValue; + else + object.negativeIntValue = options.longs === String ? $util.Long.prototype.toString.call(message.negativeIntValue) : options.longs === Number ? new $util.LongBits(message.negativeIntValue.low >>> 0, message.negativeIntValue.high >>> 0).toNumber() : message.negativeIntValue; + if (message.doubleValue != null && message.hasOwnProperty("doubleValue")) + object.doubleValue = options.json && !isFinite(message.doubleValue) ? String(message.doubleValue) : message.doubleValue; + if (message.stringValue != null && message.hasOwnProperty("stringValue")) + object.stringValue = options.bytes === String ? $util.base64.encode(message.stringValue, 0, message.stringValue.length) : options.bytes === Array ? Array.prototype.slice.call(message.stringValue) : message.stringValue; + if (message.aggregateValue != null && message.hasOwnProperty("aggregateValue")) + object.aggregateValue = message.aggregateValue; + return object; + }; + + /** + * Converts this UninterpretedOption to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption + * @instance + * @returns {Object.} JSON object + */ + UninterpretedOption.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UninterpretedOption + * @function getTypeUrl + * @memberof google.protobuf.UninterpretedOption + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UninterpretedOption.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UninterpretedOption"; + }; + + UninterpretedOption.NamePart = (function() { + + /** + * Properties of a NamePart. + * @memberof google.protobuf.UninterpretedOption + * @interface INamePart + * @property {string} namePart NamePart namePart + * @property {boolean} isExtension NamePart isExtension + */ + + /** + * Constructs a new NamePart. + * @memberof google.protobuf.UninterpretedOption + * @classdesc Represents a NamePart. + * @implements INamePart + * @constructor + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + */ + function NamePart(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * NamePart namePart. + * @member {string} namePart + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.namePart = ""; + + /** + * NamePart isExtension. + * @member {boolean} isExtension + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + */ + NamePart.prototype.isExtension = false; + + /** + * Creates a new NamePart instance using the specified properties. + * @function create + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart=} [properties] Properties to set + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart instance + */ + NamePart.create = function create(properties) { + return new NamePart(properties); + }; + + /** + * Encodes the specified NamePart message. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + writer.uint32(/* id 1, wireType 2 =*/10).string(message.namePart); + writer.uint32(/* id 2, wireType 0 =*/16).bool(message.isExtension); + return writer; + }; + + /** + * Encodes the specified NamePart message, length delimited. Does not implicitly {@link google.protobuf.UninterpretedOption.NamePart.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.INamePart} message NamePart message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + NamePart.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a NamePart message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UninterpretedOption.NamePart(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.namePart = reader.string(); + break; + } + case 2: { + message.isExtension = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + if (!message.hasOwnProperty("namePart")) + throw $util.ProtocolError("missing required 'namePart'", { instance: message }); + if (!message.hasOwnProperty("isExtension")) + throw $util.ProtocolError("missing required 'isExtension'", { instance: message }); + return message; + }; + + /** + * Decodes a NamePart message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + NamePart.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a NamePart message. + * @function verify + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + NamePart.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (!$util.isString(message.namePart)) + return "namePart: string expected"; + if (typeof message.isExtension !== "boolean") + return "isExtension: boolean expected"; + return null; + }; + + /** + * Creates a NamePart message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UninterpretedOption.NamePart} NamePart + */ + NamePart.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UninterpretedOption.NamePart) + return object; + var message = new $root.google.protobuf.UninterpretedOption.NamePart(); + if (object.namePart != null) + message.namePart = String(object.namePart); + if (object.isExtension != null) + message.isExtension = Boolean(object.isExtension); + return message; + }; + + /** + * Creates a plain object from a NamePart message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {google.protobuf.UninterpretedOption.NamePart} message NamePart + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + NamePart.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.namePart = ""; + object.isExtension = false; + } + if (message.namePart != null && message.hasOwnProperty("namePart")) + object.namePart = message.namePart; + if (message.isExtension != null && message.hasOwnProperty("isExtension")) + object.isExtension = message.isExtension; + return object; + }; + + /** + * Converts this NamePart to JSON. + * @function toJSON + * @memberof google.protobuf.UninterpretedOption.NamePart + * @instance + * @returns {Object.} JSON object + */ + NamePart.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for NamePart + * @function getTypeUrl + * @memberof google.protobuf.UninterpretedOption.NamePart + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + NamePart.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UninterpretedOption.NamePart"; + }; + + return NamePart; + })(); + + return UninterpretedOption; + })(); + + protobuf.FeatureSet = (function() { + + /** + * Properties of a FeatureSet. + * @memberof google.protobuf + * @interface IFeatureSet + * @property {google.protobuf.FeatureSet.FieldPresence|null} [fieldPresence] FeatureSet fieldPresence + * @property {google.protobuf.FeatureSet.EnumType|null} [enumType] FeatureSet enumType + * @property {google.protobuf.FeatureSet.RepeatedFieldEncoding|null} [repeatedFieldEncoding] FeatureSet repeatedFieldEncoding + * @property {google.protobuf.FeatureSet.Utf8Validation|null} [utf8Validation] FeatureSet utf8Validation + * @property {google.protobuf.FeatureSet.MessageEncoding|null} [messageEncoding] FeatureSet messageEncoding + * @property {google.protobuf.FeatureSet.JsonFormat|null} [jsonFormat] FeatureSet jsonFormat + * @property {google.protobuf.FeatureSet.EnforceNamingStyle|null} [enforceNamingStyle] FeatureSet enforceNamingStyle + * @property {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility|null} [defaultSymbolVisibility] FeatureSet defaultSymbolVisibility + */ + + /** + * Constructs a new FeatureSet. + * @memberof google.protobuf + * @classdesc Represents a FeatureSet. + * @implements IFeatureSet + * @constructor + * @param {google.protobuf.IFeatureSet=} [properties] Properties to set + */ + function FeatureSet(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FeatureSet fieldPresence. + * @member {google.protobuf.FeatureSet.FieldPresence} fieldPresence + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.fieldPresence = 0; + + /** + * FeatureSet enumType. + * @member {google.protobuf.FeatureSet.EnumType} enumType + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enumType = 0; + + /** + * FeatureSet repeatedFieldEncoding. + * @member {google.protobuf.FeatureSet.RepeatedFieldEncoding} repeatedFieldEncoding + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.repeatedFieldEncoding = 0; + + /** + * FeatureSet utf8Validation. + * @member {google.protobuf.FeatureSet.Utf8Validation} utf8Validation + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.utf8Validation = 0; + + /** + * FeatureSet messageEncoding. + * @member {google.protobuf.FeatureSet.MessageEncoding} messageEncoding + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.messageEncoding = 0; + + /** + * FeatureSet jsonFormat. + * @member {google.protobuf.FeatureSet.JsonFormat} jsonFormat + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.jsonFormat = 0; + + /** + * FeatureSet enforceNamingStyle. + * @member {google.protobuf.FeatureSet.EnforceNamingStyle} enforceNamingStyle + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.enforceNamingStyle = 0; + + /** + * FeatureSet defaultSymbolVisibility. + * @member {google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility} defaultSymbolVisibility + * @memberof google.protobuf.FeatureSet + * @instance + */ + FeatureSet.prototype.defaultSymbolVisibility = 0; + + /** + * Creates a new FeatureSet instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet + * @static + * @param {google.protobuf.IFeatureSet=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet} FeatureSet instance + */ + FeatureSet.create = function create(properties) { + return new FeatureSet(properties); + }; + + /** + * Encodes the specified FeatureSet message. Does not implicitly {@link google.protobuf.FeatureSet.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet + * @static + * @param {google.protobuf.IFeatureSet} message FeatureSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSet.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fieldPresence != null && Object.hasOwnProperty.call(message, "fieldPresence")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.fieldPresence); + if (message.enumType != null && Object.hasOwnProperty.call(message, "enumType")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.enumType); + if (message.repeatedFieldEncoding != null && Object.hasOwnProperty.call(message, "repeatedFieldEncoding")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.repeatedFieldEncoding); + if (message.utf8Validation != null && Object.hasOwnProperty.call(message, "utf8Validation")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.utf8Validation); + if (message.messageEncoding != null && Object.hasOwnProperty.call(message, "messageEncoding")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.messageEncoding); + if (message.jsonFormat != null && Object.hasOwnProperty.call(message, "jsonFormat")) + writer.uint32(/* id 6, wireType 0 =*/48).int32(message.jsonFormat); + if (message.enforceNamingStyle != null && Object.hasOwnProperty.call(message, "enforceNamingStyle")) + writer.uint32(/* id 7, wireType 0 =*/56).int32(message.enforceNamingStyle); + if (message.defaultSymbolVisibility != null && Object.hasOwnProperty.call(message, "defaultSymbolVisibility")) + writer.uint32(/* id 8, wireType 0 =*/64).int32(message.defaultSymbolVisibility); + return writer; + }; + + /** + * Encodes the specified FeatureSet message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet + * @static + * @param {google.protobuf.IFeatureSet} message FeatureSet message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSet.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSet message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet} FeatureSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSet.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.fieldPresence = reader.int32(); + break; + } + case 2: { + message.enumType = reader.int32(); + break; + } + case 3: { + message.repeatedFieldEncoding = reader.int32(); + break; + } + case 4: { + message.utf8Validation = reader.int32(); + break; + } + case 5: { + message.messageEncoding = reader.int32(); + break; + } + case 6: { + message.jsonFormat = reader.int32(); + break; + } + case 7: { + message.enforceNamingStyle = reader.int32(); + break; + } + case 8: { + message.defaultSymbolVisibility = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSet message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet} FeatureSet + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSet.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSet message. + * @function verify + * @memberof google.protobuf.FeatureSet + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSet.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) + switch (message.fieldPresence) { + default: + return "fieldPresence: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.enumType != null && message.hasOwnProperty("enumType")) + switch (message.enumType) { + default: + return "enumType: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.repeatedFieldEncoding != null && message.hasOwnProperty("repeatedFieldEncoding")) + switch (message.repeatedFieldEncoding) { + default: + return "repeatedFieldEncoding: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.utf8Validation != null && message.hasOwnProperty("utf8Validation")) + switch (message.utf8Validation) { + default: + return "utf8Validation: enum value expected"; + case 0: + case 2: + case 3: + break; + } + if (message.messageEncoding != null && message.hasOwnProperty("messageEncoding")) + switch (message.messageEncoding) { + default: + return "messageEncoding: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) + switch (message.jsonFormat) { + default: + return "jsonFormat: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + switch (message.enforceNamingStyle) { + default: + return "enforceNamingStyle: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + switch (message.defaultSymbolVisibility) { + default: + return "defaultSymbolVisibility: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 4: + break; + } + return null; + }; + + /** + * Creates a FeatureSet message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet} FeatureSet + */ + FeatureSet.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet) + return object; + var message = new $root.google.protobuf.FeatureSet(); + switch (object.fieldPresence) { + default: + if (typeof object.fieldPresence === "number") { + message.fieldPresence = object.fieldPresence; + break; + } + break; + case "FIELD_PRESENCE_UNKNOWN": + case 0: + message.fieldPresence = 0; + break; + case "EXPLICIT": + case 1: + message.fieldPresence = 1; + break; + case "IMPLICIT": + case 2: + message.fieldPresence = 2; + break; + case "LEGACY_REQUIRED": + case 3: + message.fieldPresence = 3; + break; + } + switch (object.enumType) { + default: + if (typeof object.enumType === "number") { + message.enumType = object.enumType; + break; + } + break; + case "ENUM_TYPE_UNKNOWN": + case 0: + message.enumType = 0; + break; + case "OPEN": + case 1: + message.enumType = 1; + break; + case "CLOSED": + case 2: + message.enumType = 2; + break; + } + switch (object.repeatedFieldEncoding) { + default: + if (typeof object.repeatedFieldEncoding === "number") { + message.repeatedFieldEncoding = object.repeatedFieldEncoding; + break; + } + break; + case "REPEATED_FIELD_ENCODING_UNKNOWN": + case 0: + message.repeatedFieldEncoding = 0; + break; + case "PACKED": + case 1: + message.repeatedFieldEncoding = 1; + break; + case "EXPANDED": + case 2: + message.repeatedFieldEncoding = 2; + break; + } + switch (object.utf8Validation) { + default: + if (typeof object.utf8Validation === "number") { + message.utf8Validation = object.utf8Validation; + break; + } + break; + case "UTF8_VALIDATION_UNKNOWN": + case 0: + message.utf8Validation = 0; + break; + case "VERIFY": + case 2: + message.utf8Validation = 2; + break; + case "NONE": + case 3: + message.utf8Validation = 3; + break; + } + switch (object.messageEncoding) { + default: + if (typeof object.messageEncoding === "number") { + message.messageEncoding = object.messageEncoding; + break; + } + break; + case "MESSAGE_ENCODING_UNKNOWN": + case 0: + message.messageEncoding = 0; + break; + case "LENGTH_PREFIXED": + case 1: + message.messageEncoding = 1; + break; + case "DELIMITED": + case 2: + message.messageEncoding = 2; + break; + } + switch (object.jsonFormat) { + default: + if (typeof object.jsonFormat === "number") { + message.jsonFormat = object.jsonFormat; + break; + } + break; + case "JSON_FORMAT_UNKNOWN": + case 0: + message.jsonFormat = 0; + break; + case "ALLOW": + case 1: + message.jsonFormat = 1; + break; + case "LEGACY_BEST_EFFORT": + case 2: + message.jsonFormat = 2; + break; + } + switch (object.enforceNamingStyle) { + default: + if (typeof object.enforceNamingStyle === "number") { + message.enforceNamingStyle = object.enforceNamingStyle; + break; + } + break; + case "ENFORCE_NAMING_STYLE_UNKNOWN": + case 0: + message.enforceNamingStyle = 0; + break; + case "STYLE2024": + case 1: + message.enforceNamingStyle = 1; + break; + case "STYLE_LEGACY": + case 2: + message.enforceNamingStyle = 2; + break; + } + switch (object.defaultSymbolVisibility) { + default: + if (typeof object.defaultSymbolVisibility === "number") { + message.defaultSymbolVisibility = object.defaultSymbolVisibility; + break; + } + break; + case "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": + case 0: + message.defaultSymbolVisibility = 0; + break; + case "EXPORT_ALL": + case 1: + message.defaultSymbolVisibility = 1; + break; + case "EXPORT_TOP_LEVEL": + case 2: + message.defaultSymbolVisibility = 2; + break; + case "LOCAL_ALL": + case 3: + message.defaultSymbolVisibility = 3; + break; + case "STRICT": + case 4: + message.defaultSymbolVisibility = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from a FeatureSet message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet + * @static + * @param {google.protobuf.FeatureSet} message FeatureSet + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSet.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.fieldPresence = options.enums === String ? "FIELD_PRESENCE_UNKNOWN" : 0; + object.enumType = options.enums === String ? "ENUM_TYPE_UNKNOWN" : 0; + object.repeatedFieldEncoding = options.enums === String ? "REPEATED_FIELD_ENCODING_UNKNOWN" : 0; + object.utf8Validation = options.enums === String ? "UTF8_VALIDATION_UNKNOWN" : 0; + object.messageEncoding = options.enums === String ? "MESSAGE_ENCODING_UNKNOWN" : 0; + object.jsonFormat = options.enums === String ? "JSON_FORMAT_UNKNOWN" : 0; + object.enforceNamingStyle = options.enums === String ? "ENFORCE_NAMING_STYLE_UNKNOWN" : 0; + object.defaultSymbolVisibility = options.enums === String ? "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN" : 0; + } + if (message.fieldPresence != null && message.hasOwnProperty("fieldPresence")) + object.fieldPresence = options.enums === String ? $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] === undefined ? message.fieldPresence : $root.google.protobuf.FeatureSet.FieldPresence[message.fieldPresence] : message.fieldPresence; + if (message.enumType != null && message.hasOwnProperty("enumType")) + object.enumType = options.enums === String ? $root.google.protobuf.FeatureSet.EnumType[message.enumType] === undefined ? message.enumType : $root.google.protobuf.FeatureSet.EnumType[message.enumType] : message.enumType; + if (message.repeatedFieldEncoding != null && message.hasOwnProperty("repeatedFieldEncoding")) + object.repeatedFieldEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.RepeatedFieldEncoding[message.repeatedFieldEncoding] === undefined ? message.repeatedFieldEncoding : $root.google.protobuf.FeatureSet.RepeatedFieldEncoding[message.repeatedFieldEncoding] : message.repeatedFieldEncoding; + if (message.utf8Validation != null && message.hasOwnProperty("utf8Validation")) + object.utf8Validation = options.enums === String ? $root.google.protobuf.FeatureSet.Utf8Validation[message.utf8Validation] === undefined ? message.utf8Validation : $root.google.protobuf.FeatureSet.Utf8Validation[message.utf8Validation] : message.utf8Validation; + if (message.messageEncoding != null && message.hasOwnProperty("messageEncoding")) + object.messageEncoding = options.enums === String ? $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] === undefined ? message.messageEncoding : $root.google.protobuf.FeatureSet.MessageEncoding[message.messageEncoding] : message.messageEncoding; + if (message.jsonFormat != null && message.hasOwnProperty("jsonFormat")) + object.jsonFormat = options.enums === String ? $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] === undefined ? message.jsonFormat : $root.google.protobuf.FeatureSet.JsonFormat[message.jsonFormat] : message.jsonFormat; + if (message.enforceNamingStyle != null && message.hasOwnProperty("enforceNamingStyle")) + object.enforceNamingStyle = options.enums === String ? $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] === undefined ? message.enforceNamingStyle : $root.google.protobuf.FeatureSet.EnforceNamingStyle[message.enforceNamingStyle] : message.enforceNamingStyle; + if (message.defaultSymbolVisibility != null && message.hasOwnProperty("defaultSymbolVisibility")) + object.defaultSymbolVisibility = options.enums === String ? $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] === undefined ? message.defaultSymbolVisibility : $root.google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility[message.defaultSymbolVisibility] : message.defaultSymbolVisibility; + return object; + }; + + /** + * Converts this FeatureSet to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet + * @instance + * @returns {Object.} JSON object + */ + FeatureSet.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSet + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSet.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet"; + }; + + /** + * FieldPresence enum. + * @name google.protobuf.FeatureSet.FieldPresence + * @enum {number} + * @property {number} FIELD_PRESENCE_UNKNOWN=0 FIELD_PRESENCE_UNKNOWN value + * @property {number} EXPLICIT=1 EXPLICIT value + * @property {number} IMPLICIT=2 IMPLICIT value + * @property {number} LEGACY_REQUIRED=3 LEGACY_REQUIRED value + */ + FeatureSet.FieldPresence = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "FIELD_PRESENCE_UNKNOWN"] = 0; + values[valuesById[1] = "EXPLICIT"] = 1; + values[valuesById[2] = "IMPLICIT"] = 2; + values[valuesById[3] = "LEGACY_REQUIRED"] = 3; + return values; + })(); + + /** + * EnumType enum. + * @name google.protobuf.FeatureSet.EnumType + * @enum {number} + * @property {number} ENUM_TYPE_UNKNOWN=0 ENUM_TYPE_UNKNOWN value + * @property {number} OPEN=1 OPEN value + * @property {number} CLOSED=2 CLOSED value + */ + FeatureSet.EnumType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENUM_TYPE_UNKNOWN"] = 0; + values[valuesById[1] = "OPEN"] = 1; + values[valuesById[2] = "CLOSED"] = 2; + return values; + })(); + + /** + * RepeatedFieldEncoding enum. + * @name google.protobuf.FeatureSet.RepeatedFieldEncoding + * @enum {number} + * @property {number} REPEATED_FIELD_ENCODING_UNKNOWN=0 REPEATED_FIELD_ENCODING_UNKNOWN value + * @property {number} PACKED=1 PACKED value + * @property {number} EXPANDED=2 EXPANDED value + */ + FeatureSet.RepeatedFieldEncoding = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "REPEATED_FIELD_ENCODING_UNKNOWN"] = 0; + values[valuesById[1] = "PACKED"] = 1; + values[valuesById[2] = "EXPANDED"] = 2; + return values; + })(); + + /** + * Utf8Validation enum. + * @name google.protobuf.FeatureSet.Utf8Validation + * @enum {number} + * @property {number} UTF8_VALIDATION_UNKNOWN=0 UTF8_VALIDATION_UNKNOWN value + * @property {number} VERIFY=2 VERIFY value + * @property {number} NONE=3 NONE value + */ + FeatureSet.Utf8Validation = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "UTF8_VALIDATION_UNKNOWN"] = 0; + values[valuesById[2] = "VERIFY"] = 2; + values[valuesById[3] = "NONE"] = 3; + return values; + })(); + + /** + * MessageEncoding enum. + * @name google.protobuf.FeatureSet.MessageEncoding + * @enum {number} + * @property {number} MESSAGE_ENCODING_UNKNOWN=0 MESSAGE_ENCODING_UNKNOWN value + * @property {number} LENGTH_PREFIXED=1 LENGTH_PREFIXED value + * @property {number} DELIMITED=2 DELIMITED value + */ + FeatureSet.MessageEncoding = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "MESSAGE_ENCODING_UNKNOWN"] = 0; + values[valuesById[1] = "LENGTH_PREFIXED"] = 1; + values[valuesById[2] = "DELIMITED"] = 2; + return values; + })(); + + /** + * JsonFormat enum. + * @name google.protobuf.FeatureSet.JsonFormat + * @enum {number} + * @property {number} JSON_FORMAT_UNKNOWN=0 JSON_FORMAT_UNKNOWN value + * @property {number} ALLOW=1 ALLOW value + * @property {number} LEGACY_BEST_EFFORT=2 LEGACY_BEST_EFFORT value + */ + FeatureSet.JsonFormat = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "JSON_FORMAT_UNKNOWN"] = 0; + values[valuesById[1] = "ALLOW"] = 1; + values[valuesById[2] = "LEGACY_BEST_EFFORT"] = 2; + return values; + })(); + + /** + * EnforceNamingStyle enum. + * @name google.protobuf.FeatureSet.EnforceNamingStyle + * @enum {number} + * @property {number} ENFORCE_NAMING_STYLE_UNKNOWN=0 ENFORCE_NAMING_STYLE_UNKNOWN value + * @property {number} STYLE2024=1 STYLE2024 value + * @property {number} STYLE_LEGACY=2 STYLE_LEGACY value + */ + FeatureSet.EnforceNamingStyle = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "ENFORCE_NAMING_STYLE_UNKNOWN"] = 0; + values[valuesById[1] = "STYLE2024"] = 1; + values[valuesById[2] = "STYLE_LEGACY"] = 2; + return values; + })(); + + FeatureSet.VisibilityFeature = (function() { + + /** + * Properties of a VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @interface IVisibilityFeature + */ + + /** + * Constructs a new VisibilityFeature. + * @memberof google.protobuf.FeatureSet + * @classdesc Represents a VisibilityFeature. + * @implements IVisibilityFeature + * @constructor + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + */ + function VisibilityFeature(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new VisibilityFeature instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature=} [properties] Properties to set + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature instance + */ + VisibilityFeature.create = function create(properties) { + return new VisibilityFeature(properties); + }; + + /** + * Encodes the specified VisibilityFeature message. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified VisibilityFeature message, length delimited. Does not implicitly {@link google.protobuf.FeatureSet.VisibilityFeature.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.IVisibilityFeature} message VisibilityFeature message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + VisibilityFeature.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSet.VisibilityFeature(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a VisibilityFeature message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + VisibilityFeature.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a VisibilityFeature message. + * @function verify + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + VisibilityFeature.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates a VisibilityFeature message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSet.VisibilityFeature} VisibilityFeature + */ + VisibilityFeature.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSet.VisibilityFeature) + return object; + return new $root.google.protobuf.FeatureSet.VisibilityFeature(); + }; + + /** + * Creates a plain object from a VisibilityFeature message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {google.protobuf.FeatureSet.VisibilityFeature} message VisibilityFeature + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + VisibilityFeature.toObject = function toObject() { + return {}; + }; + + /** + * Converts this VisibilityFeature to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @instance + * @returns {Object.} JSON object + */ + VisibilityFeature.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for VisibilityFeature + * @function getTypeUrl + * @memberof google.protobuf.FeatureSet.VisibilityFeature + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + VisibilityFeature.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSet.VisibilityFeature"; + }; + + /** + * DefaultSymbolVisibility enum. + * @name google.protobuf.FeatureSet.VisibilityFeature.DefaultSymbolVisibility + * @enum {number} + * @property {number} DEFAULT_SYMBOL_VISIBILITY_UNKNOWN=0 DEFAULT_SYMBOL_VISIBILITY_UNKNOWN value + * @property {number} EXPORT_ALL=1 EXPORT_ALL value + * @property {number} EXPORT_TOP_LEVEL=2 EXPORT_TOP_LEVEL value + * @property {number} LOCAL_ALL=3 LOCAL_ALL value + * @property {number} STRICT=4 STRICT value + */ + VisibilityFeature.DefaultSymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN"] = 0; + values[valuesById[1] = "EXPORT_ALL"] = 1; + values[valuesById[2] = "EXPORT_TOP_LEVEL"] = 2; + values[valuesById[3] = "LOCAL_ALL"] = 3; + values[valuesById[4] = "STRICT"] = 4; + return values; + })(); + + return VisibilityFeature; + })(); + + return FeatureSet; + })(); + + protobuf.FeatureSetDefaults = (function() { + + /** + * Properties of a FeatureSetDefaults. + * @memberof google.protobuf + * @interface IFeatureSetDefaults + * @property {Array.|null} [defaults] FeatureSetDefaults defaults + * @property {google.protobuf.Edition|null} [minimumEdition] FeatureSetDefaults minimumEdition + * @property {google.protobuf.Edition|null} [maximumEdition] FeatureSetDefaults maximumEdition + */ + + /** + * Constructs a new FeatureSetDefaults. + * @memberof google.protobuf + * @classdesc Represents a FeatureSetDefaults. + * @implements IFeatureSetDefaults + * @constructor + * @param {google.protobuf.IFeatureSetDefaults=} [properties] Properties to set + */ + function FeatureSetDefaults(properties) { + this.defaults = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FeatureSetDefaults defaults. + * @member {Array.} defaults + * @memberof google.protobuf.FeatureSetDefaults + * @instance + */ + FeatureSetDefaults.prototype.defaults = $util.emptyArray; + + /** + * FeatureSetDefaults minimumEdition. + * @member {google.protobuf.Edition} minimumEdition + * @memberof google.protobuf.FeatureSetDefaults + * @instance + */ + FeatureSetDefaults.prototype.minimumEdition = 0; + + /** + * FeatureSetDefaults maximumEdition. + * @member {google.protobuf.Edition} maximumEdition + * @memberof google.protobuf.FeatureSetDefaults + * @instance + */ + FeatureSetDefaults.prototype.maximumEdition = 0; + + /** + * Creates a new FeatureSetDefaults instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.IFeatureSetDefaults=} [properties] Properties to set + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults instance + */ + FeatureSetDefaults.create = function create(properties) { + return new FeatureSetDefaults(properties); + }; + + /** + * Encodes the specified FeatureSetDefaults message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.IFeatureSetDefaults} message FeatureSetDefaults message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetDefaults.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.defaults != null && message.defaults.length) + for (var i = 0; i < message.defaults.length; ++i) + $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.encode(message.defaults[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.minimumEdition != null && Object.hasOwnProperty.call(message, "minimumEdition")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.minimumEdition); + if (message.maximumEdition != null && Object.hasOwnProperty.call(message, "maximumEdition")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.maximumEdition); + return writer; + }; + + /** + * Encodes the specified FeatureSetDefaults message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.IFeatureSetDefaults} message FeatureSetDefaults message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetDefaults.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetDefaults.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSetDefaults(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.defaults && message.defaults.length)) + message.defaults = []; + message.defaults.push($root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.decode(reader, reader.uint32())); + break; + } + case 4: { + message.minimumEdition = reader.int32(); + break; + } + case 5: { + message.maximumEdition = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSetDefaults message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetDefaults.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSetDefaults message. + * @function verify + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSetDefaults.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.defaults != null && message.hasOwnProperty("defaults")) { + if (!Array.isArray(message.defaults)) + return "defaults: array expected"; + for (var i = 0; i < message.defaults.length; ++i) { + var error = $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify(message.defaults[i]); + if (error) + return "defaults." + error; + } + } + if (message.minimumEdition != null && message.hasOwnProperty("minimumEdition")) + switch (message.minimumEdition) { + default: + return "minimumEdition: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.maximumEdition != null && message.hasOwnProperty("maximumEdition")) + switch (message.maximumEdition) { + default: + return "maximumEdition: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + return null; + }; + + /** + * Creates a FeatureSetDefaults message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSetDefaults} FeatureSetDefaults + */ + FeatureSetDefaults.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSetDefaults) + return object; + var message = new $root.google.protobuf.FeatureSetDefaults(); + if (object.defaults) { + if (!Array.isArray(object.defaults)) + throw TypeError(".google.protobuf.FeatureSetDefaults.defaults: array expected"); + message.defaults = []; + for (var i = 0; i < object.defaults.length; ++i) { + if (typeof object.defaults[i] !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.defaults: object expected"); + message.defaults[i] = $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fromObject(object.defaults[i]); + } + } + switch (object.minimumEdition) { + default: + if (typeof object.minimumEdition === "number") { + message.minimumEdition = object.minimumEdition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.minimumEdition = 0; + break; + case "EDITION_LEGACY": + case 900: + message.minimumEdition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.minimumEdition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.minimumEdition = 999; + break; + case "EDITION_2023": + case 1000: + message.minimumEdition = 1000; + break; + case "EDITION_2024": + case 1001: + message.minimumEdition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.minimumEdition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.minimumEdition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.minimumEdition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.minimumEdition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.minimumEdition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.minimumEdition = 2147483647; + break; + } + switch (object.maximumEdition) { + default: + if (typeof object.maximumEdition === "number") { + message.maximumEdition = object.maximumEdition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.maximumEdition = 0; + break; + case "EDITION_LEGACY": + case 900: + message.maximumEdition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.maximumEdition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.maximumEdition = 999; + break; + case "EDITION_2023": + case 1000: + message.maximumEdition = 1000; + break; + case "EDITION_2024": + case 1001: + message.maximumEdition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.maximumEdition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.maximumEdition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.maximumEdition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.maximumEdition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.maximumEdition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.maximumEdition = 2147483647; + break; + } + return message; + }; + + /** + * Creates a plain object from a FeatureSetDefaults message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {google.protobuf.FeatureSetDefaults} message FeatureSetDefaults + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSetDefaults.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.defaults = []; + if (options.defaults) { + object.minimumEdition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.maximumEdition = options.enums === String ? "EDITION_UNKNOWN" : 0; + } + if (message.defaults && message.defaults.length) { + object.defaults = []; + for (var j = 0; j < message.defaults.length; ++j) + object.defaults[j] = $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.toObject(message.defaults[j], options); + } + if (message.minimumEdition != null && message.hasOwnProperty("minimumEdition")) + object.minimumEdition = options.enums === String ? $root.google.protobuf.Edition[message.minimumEdition] === undefined ? message.minimumEdition : $root.google.protobuf.Edition[message.minimumEdition] : message.minimumEdition; + if (message.maximumEdition != null && message.hasOwnProperty("maximumEdition")) + object.maximumEdition = options.enums === String ? $root.google.protobuf.Edition[message.maximumEdition] === undefined ? message.maximumEdition : $root.google.protobuf.Edition[message.maximumEdition] : message.maximumEdition; + return object; + }; + + /** + * Converts this FeatureSetDefaults to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSetDefaults + * @instance + * @returns {Object.} JSON object + */ + FeatureSetDefaults.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSetDefaults + * @function getTypeUrl + * @memberof google.protobuf.FeatureSetDefaults + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSetDefaults.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSetDefaults"; + }; + + FeatureSetDefaults.FeatureSetEditionDefault = (function() { + + /** + * Properties of a FeatureSetEditionDefault. + * @memberof google.protobuf.FeatureSetDefaults + * @interface IFeatureSetEditionDefault + * @property {google.protobuf.Edition|null} [edition] FeatureSetEditionDefault edition + * @property {google.protobuf.IFeatureSet|null} [overridableFeatures] FeatureSetEditionDefault overridableFeatures + * @property {google.protobuf.IFeatureSet|null} [fixedFeatures] FeatureSetEditionDefault fixedFeatures + */ + + /** + * Constructs a new FeatureSetEditionDefault. + * @memberof google.protobuf.FeatureSetDefaults + * @classdesc Represents a FeatureSetEditionDefault. + * @implements IFeatureSetEditionDefault + * @constructor + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault=} [properties] Properties to set + */ + function FeatureSetEditionDefault(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FeatureSetEditionDefault edition. + * @member {google.protobuf.Edition} edition + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.edition = 0; + + /** + * FeatureSetEditionDefault overridableFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} overridableFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.overridableFeatures = null; + + /** + * FeatureSetEditionDefault fixedFeatures. + * @member {google.protobuf.IFeatureSet|null|undefined} fixedFeatures + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + */ + FeatureSetEditionDefault.prototype.fixedFeatures = null; + + /** + * Creates a new FeatureSetEditionDefault instance using the specified properties. + * @function create + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault=} [properties] Properties to set + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault instance + */ + FeatureSetEditionDefault.create = function create(properties) { + return new FeatureSetEditionDefault(properties); + }; + + /** + * Encodes the specified FeatureSetEditionDefault message. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault} message FeatureSetEditionDefault message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetEditionDefault.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.edition != null && Object.hasOwnProperty.call(message, "edition")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.edition); + if (message.overridableFeatures != null && Object.hasOwnProperty.call(message, "overridableFeatures")) + $root.google.protobuf.FeatureSet.encode(message.overridableFeatures, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.fixedFeatures != null && Object.hasOwnProperty.call(message, "fixedFeatures")) + $root.google.protobuf.FeatureSet.encode(message.fixedFeatures, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified FeatureSetEditionDefault message, length delimited. Does not implicitly {@link google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.IFeatureSetEditionDefault} message FeatureSetEditionDefault message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FeatureSetEditionDefault.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetEditionDefault.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 3: { + message.edition = reader.int32(); + break; + } + case 4: { + message.overridableFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + case 5: { + message.fixedFeatures = $root.google.protobuf.FeatureSet.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FeatureSetEditionDefault message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FeatureSetEditionDefault.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FeatureSetEditionDefault message. + * @function verify + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FeatureSetEditionDefault.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.edition != null && message.hasOwnProperty("edition")) + switch (message.edition) { + default: + return "edition: enum value expected"; + case 0: + case 900: + case 998: + case 999: + case 1000: + case 1001: + case 1: + case 2: + case 99997: + case 99998: + case 99999: + case 2147483647: + break; + } + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.overridableFeatures); + if (error) + return "overridableFeatures." + error; + } + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) { + var error = $root.google.protobuf.FeatureSet.verify(message.fixedFeatures); + if (error) + return "fixedFeatures." + error; + } + return null; + }; + + /** + * Creates a FeatureSetEditionDefault message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} FeatureSetEditionDefault + */ + FeatureSetEditionDefault.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault) + return object; + var message = new $root.google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault(); + switch (object.edition) { + default: + if (typeof object.edition === "number") { + message.edition = object.edition; + break; + } + break; + case "EDITION_UNKNOWN": + case 0: + message.edition = 0; + break; + case "EDITION_LEGACY": + case 900: + message.edition = 900; + break; + case "EDITION_PROTO2": + case 998: + message.edition = 998; + break; + case "EDITION_PROTO3": + case 999: + message.edition = 999; + break; + case "EDITION_2023": + case 1000: + message.edition = 1000; + break; + case "EDITION_2024": + case 1001: + message.edition = 1001; + break; + case "EDITION_1_TEST_ONLY": + case 1: + message.edition = 1; + break; + case "EDITION_2_TEST_ONLY": + case 2: + message.edition = 2; + break; + case "EDITION_99997_TEST_ONLY": + case 99997: + message.edition = 99997; + break; + case "EDITION_99998_TEST_ONLY": + case 99998: + message.edition = 99998; + break; + case "EDITION_99999_TEST_ONLY": + case 99999: + message.edition = 99999; + break; + case "EDITION_MAX": + case 2147483647: + message.edition = 2147483647; + break; + } + if (object.overridableFeatures != null) { + if (typeof object.overridableFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.overridableFeatures: object expected"); + message.overridableFeatures = $root.google.protobuf.FeatureSet.fromObject(object.overridableFeatures); + } + if (object.fixedFeatures != null) { + if (typeof object.fixedFeatures !== "object") + throw TypeError(".google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault.fixedFeatures: object expected"); + message.fixedFeatures = $root.google.protobuf.FeatureSet.fromObject(object.fixedFeatures); + } + return message; + }; + + /** + * Creates a plain object from a FeatureSetEditionDefault message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault} message FeatureSetEditionDefault + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FeatureSetEditionDefault.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.edition = options.enums === String ? "EDITION_UNKNOWN" : 0; + object.overridableFeatures = null; + object.fixedFeatures = null; + } + if (message.edition != null && message.hasOwnProperty("edition")) + object.edition = options.enums === String ? $root.google.protobuf.Edition[message.edition] === undefined ? message.edition : $root.google.protobuf.Edition[message.edition] : message.edition; + if (message.overridableFeatures != null && message.hasOwnProperty("overridableFeatures")) + object.overridableFeatures = $root.google.protobuf.FeatureSet.toObject(message.overridableFeatures, options); + if (message.fixedFeatures != null && message.hasOwnProperty("fixedFeatures")) + object.fixedFeatures = $root.google.protobuf.FeatureSet.toObject(message.fixedFeatures, options); + return object; + }; + + /** + * Converts this FeatureSetEditionDefault to JSON. + * @function toJSON + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @instance + * @returns {Object.} JSON object + */ + FeatureSetEditionDefault.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FeatureSetEditionDefault + * @function getTypeUrl + * @memberof google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FeatureSetEditionDefault.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault"; + }; + + return FeatureSetEditionDefault; + })(); + + return FeatureSetDefaults; + })(); + + protobuf.SourceCodeInfo = (function() { + + /** + * Properties of a SourceCodeInfo. + * @memberof google.protobuf + * @interface ISourceCodeInfo + * @property {Array.|null} [location] SourceCodeInfo location + */ + + /** + * Constructs a new SourceCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a SourceCodeInfo. + * @implements ISourceCodeInfo + * @constructor + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + */ + function SourceCodeInfo(properties) { + this.location = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SourceCodeInfo location. + * @member {Array.} location + * @memberof google.protobuf.SourceCodeInfo + * @instance + */ + SourceCodeInfo.prototype.location = $util.emptyArray; + + /** + * Creates a new SourceCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo instance + */ + SourceCodeInfo.create = function create(properties) { + return new SourceCodeInfo(properties); + }; + + /** + * Encodes the specified SourceCodeInfo message. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.location != null && message.location.length) + for (var i = 0; i < message.location.length; ++i) + $root.google.protobuf.SourceCodeInfo.Location.encode(message.location[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SourceCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.ISourceCodeInfo} message SourceCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SourceCodeInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.SourceCodeInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.location && message.location.length)) + message.location = []; + message.location.push($root.google.protobuf.SourceCodeInfo.Location.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SourceCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SourceCodeInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SourceCodeInfo message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SourceCodeInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.location != null && message.hasOwnProperty("location")) { + if (!Array.isArray(message.location)) + return "location: array expected"; + for (var i = 0; i < message.location.length; ++i) { + var error = $root.google.protobuf.SourceCodeInfo.Location.verify(message.location[i]); + if (error) + return "location." + error; + } + } + return null; + }; + + /** + * Creates a SourceCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo} SourceCodeInfo + */ + SourceCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo) + return object; + var message = new $root.google.protobuf.SourceCodeInfo(); + if (object.location) { + if (!Array.isArray(object.location)) + throw TypeError(".google.protobuf.SourceCodeInfo.location: array expected"); + message.location = []; + for (var i = 0; i < object.location.length; ++i) { + if (typeof object.location[i] !== "object") + throw TypeError(".google.protobuf.SourceCodeInfo.location: object expected"); + message.location[i] = $root.google.protobuf.SourceCodeInfo.Location.fromObject(object.location[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a SourceCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {google.protobuf.SourceCodeInfo} message SourceCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SourceCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.location = []; + if (message.location && message.location.length) { + object.location = []; + for (var j = 0; j < message.location.length; ++j) + object.location[j] = $root.google.protobuf.SourceCodeInfo.Location.toObject(message.location[j], options); + } + return object; + }; + + /** + * Converts this SourceCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo + * @instance + * @returns {Object.} JSON object + */ + SourceCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SourceCodeInfo + * @function getTypeUrl + * @memberof google.protobuf.SourceCodeInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SourceCodeInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.SourceCodeInfo"; + }; + + SourceCodeInfo.Location = (function() { + + /** + * Properties of a Location. + * @memberof google.protobuf.SourceCodeInfo + * @interface ILocation + * @property {Array.|null} [path] Location path + * @property {Array.|null} [span] Location span + * @property {string|null} [leadingComments] Location leadingComments + * @property {string|null} [trailingComments] Location trailingComments + * @property {Array.|null} [leadingDetachedComments] Location leadingDetachedComments + */ + + /** + * Constructs a new Location. + * @memberof google.protobuf.SourceCodeInfo + * @classdesc Represents a Location. + * @implements ILocation + * @constructor + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + */ + function Location(properties) { + this.path = []; + this.span = []; + this.leadingDetachedComments = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Location path. + * @member {Array.} path + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.path = $util.emptyArray; + + /** + * Location span. + * @member {Array.} span + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.span = $util.emptyArray; + + /** + * Location leadingComments. + * @member {string} leadingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingComments = ""; + + /** + * Location trailingComments. + * @member {string} trailingComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.trailingComments = ""; + + /** + * Location leadingDetachedComments. + * @member {Array.} leadingDetachedComments + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + */ + Location.prototype.leadingDetachedComments = $util.emptyArray; + + /** + * Creates a new Location instance using the specified properties. + * @function create + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation=} [properties] Properties to set + * @returns {google.protobuf.SourceCodeInfo.Location} Location instance + */ + Location.create = function create(properties) { + return new Location(properties); + }; + + /** + * Encodes the specified Location message. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/10).fork(); + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]); + writer.ldelim(); + } + if (message.span != null && message.span.length) { + writer.uint32(/* id 2, wireType 2 =*/18).fork(); + for (var i = 0; i < message.span.length; ++i) + writer.int32(message.span[i]); + writer.ldelim(); + } + if (message.leadingComments != null && Object.hasOwnProperty.call(message, "leadingComments")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.leadingComments); + if (message.trailingComments != null && Object.hasOwnProperty.call(message, "trailingComments")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.trailingComments); + if (message.leadingDetachedComments != null && message.leadingDetachedComments.length) + for (var i = 0; i < message.leadingDetachedComments.length; ++i) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.leadingDetachedComments[i]); + return writer; + }; + + /** + * Encodes the specified Location message, length delimited. Does not implicitly {@link google.protobuf.SourceCodeInfo.Location.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.ILocation} message Location message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Location.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Location message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.SourceCodeInfo.Location(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.path && message.path.length)) + message.path = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.path.push(reader.int32()); + } else + message.path.push(reader.int32()); + break; + } + case 2: { + if (!(message.span && message.span.length)) + message.span = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.span.push(reader.int32()); + } else + message.span.push(reader.int32()); + break; + } + case 3: { + message.leadingComments = reader.string(); + break; + } + case 4: { + message.trailingComments = reader.string(); + break; + } + case 6: { + if (!(message.leadingDetachedComments && message.leadingDetachedComments.length)) + message.leadingDetachedComments = []; + message.leadingDetachedComments.push(reader.string()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Location message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.SourceCodeInfo.Location} Location + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Location.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Location message. + * @function verify + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Location.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.path != null && message.hasOwnProperty("path")) { + if (!Array.isArray(message.path)) + return "path: array expected"; + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return "path: integer[] expected"; + } + if (message.span != null && message.hasOwnProperty("span")) { + if (!Array.isArray(message.span)) + return "span: array expected"; + for (var i = 0; i < message.span.length; ++i) + if (!$util.isInteger(message.span[i])) + return "span: integer[] expected"; + } + if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + if (!$util.isString(message.leadingComments)) + return "leadingComments: string expected"; + if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + if (!$util.isString(message.trailingComments)) + return "trailingComments: string expected"; + if (message.leadingDetachedComments != null && message.hasOwnProperty("leadingDetachedComments")) { + if (!Array.isArray(message.leadingDetachedComments)) + return "leadingDetachedComments: array expected"; + for (var i = 0; i < message.leadingDetachedComments.length; ++i) + if (!$util.isString(message.leadingDetachedComments[i])) + return "leadingDetachedComments: string[] expected"; + } + return null; + }; + + /** + * Creates a Location message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.SourceCodeInfo.Location} Location + */ + Location.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.SourceCodeInfo.Location) + return object; + var message = new $root.google.protobuf.SourceCodeInfo.Location(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.span) { + if (!Array.isArray(object.span)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.span: array expected"); + message.span = []; + for (var i = 0; i < object.span.length; ++i) + message.span[i] = object.span[i] | 0; + } + if (object.leadingComments != null) + message.leadingComments = String(object.leadingComments); + if (object.trailingComments != null) + message.trailingComments = String(object.trailingComments); + if (object.leadingDetachedComments) { + if (!Array.isArray(object.leadingDetachedComments)) + throw TypeError(".google.protobuf.SourceCodeInfo.Location.leadingDetachedComments: array expected"); + message.leadingDetachedComments = []; + for (var i = 0; i < object.leadingDetachedComments.length; ++i) + message.leadingDetachedComments[i] = String(object.leadingDetachedComments[i]); + } + return message; + }; + + /** + * Creates a plain object from a Location message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {google.protobuf.SourceCodeInfo.Location} message Location + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Location.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) { + object.path = []; + object.span = []; + object.leadingDetachedComments = []; + } + if (options.defaults) { + object.leadingComments = ""; + object.trailingComments = ""; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.span && message.span.length) { + object.span = []; + for (var j = 0; j < message.span.length; ++j) + object.span[j] = message.span[j]; + } + if (message.leadingComments != null && message.hasOwnProperty("leadingComments")) + object.leadingComments = message.leadingComments; + if (message.trailingComments != null && message.hasOwnProperty("trailingComments")) + object.trailingComments = message.trailingComments; + if (message.leadingDetachedComments && message.leadingDetachedComments.length) { + object.leadingDetachedComments = []; + for (var j = 0; j < message.leadingDetachedComments.length; ++j) + object.leadingDetachedComments[j] = message.leadingDetachedComments[j]; + } + return object; + }; + + /** + * Converts this Location to JSON. + * @function toJSON + * @memberof google.protobuf.SourceCodeInfo.Location + * @instance + * @returns {Object.} JSON object + */ + Location.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Location + * @function getTypeUrl + * @memberof google.protobuf.SourceCodeInfo.Location + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Location.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.SourceCodeInfo.Location"; + }; + + return Location; + })(); + + return SourceCodeInfo; + })(); + + protobuf.GeneratedCodeInfo = (function() { + + /** + * Properties of a GeneratedCodeInfo. + * @memberof google.protobuf + * @interface IGeneratedCodeInfo + * @property {Array.|null} [annotation] GeneratedCodeInfo annotation + */ + + /** + * Constructs a new GeneratedCodeInfo. + * @memberof google.protobuf + * @classdesc Represents a GeneratedCodeInfo. + * @implements IGeneratedCodeInfo + * @constructor + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + */ + function GeneratedCodeInfo(properties) { + this.annotation = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GeneratedCodeInfo annotation. + * @member {Array.} annotation + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + */ + GeneratedCodeInfo.prototype.annotation = $util.emptyArray; + + /** + * Creates a new GeneratedCodeInfo instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo instance + */ + GeneratedCodeInfo.create = function create(properties) { + return new GeneratedCodeInfo(properties); + }; + + /** + * Encodes the specified GeneratedCodeInfo message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.annotation != null && message.annotation.length) + for (var i = 0; i < message.annotation.length; ++i) + $root.google.protobuf.GeneratedCodeInfo.Annotation.encode(message.annotation[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified GeneratedCodeInfo message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.IGeneratedCodeInfo} message GeneratedCodeInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GeneratedCodeInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.GeneratedCodeInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.annotation && message.annotation.length)) + message.annotation = []; + message.annotation.push($root.google.protobuf.GeneratedCodeInfo.Annotation.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GeneratedCodeInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GeneratedCodeInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GeneratedCodeInfo message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GeneratedCodeInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.annotation != null && message.hasOwnProperty("annotation")) { + if (!Array.isArray(message.annotation)) + return "annotation: array expected"; + for (var i = 0; i < message.annotation.length; ++i) { + var error = $root.google.protobuf.GeneratedCodeInfo.Annotation.verify(message.annotation[i]); + if (error) + return "annotation." + error; + } + } + return null; + }; + + /** + * Creates a GeneratedCodeInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo} GeneratedCodeInfo + */ + GeneratedCodeInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo(); + if (object.annotation) { + if (!Array.isArray(object.annotation)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: array expected"); + message.annotation = []; + for (var i = 0; i < object.annotation.length; ++i) { + if (typeof object.annotation[i] !== "object") + throw TypeError(".google.protobuf.GeneratedCodeInfo.annotation: object expected"); + message.annotation[i] = $root.google.protobuf.GeneratedCodeInfo.Annotation.fromObject(object.annotation[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a GeneratedCodeInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {google.protobuf.GeneratedCodeInfo} message GeneratedCodeInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GeneratedCodeInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.annotation = []; + if (message.annotation && message.annotation.length) { + object.annotation = []; + for (var j = 0; j < message.annotation.length; ++j) + object.annotation[j] = $root.google.protobuf.GeneratedCodeInfo.Annotation.toObject(message.annotation[j], options); + } + return object; + }; + + /** + * Converts this GeneratedCodeInfo to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo + * @instance + * @returns {Object.} JSON object + */ + GeneratedCodeInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GeneratedCodeInfo + * @function getTypeUrl + * @memberof google.protobuf.GeneratedCodeInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GeneratedCodeInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.GeneratedCodeInfo"; + }; + + GeneratedCodeInfo.Annotation = (function() { + + /** + * Properties of an Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @interface IAnnotation + * @property {Array.|null} [path] Annotation path + * @property {string|null} [sourceFile] Annotation sourceFile + * @property {number|null} [begin] Annotation begin + * @property {number|null} [end] Annotation end + * @property {google.protobuf.GeneratedCodeInfo.Annotation.Semantic|null} [semantic] Annotation semantic + */ + + /** + * Constructs a new Annotation. + * @memberof google.protobuf.GeneratedCodeInfo + * @classdesc Represents an Annotation. + * @implements IAnnotation + * @constructor + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + */ + function Annotation(properties) { + this.path = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Annotation path. + * @member {Array.} path + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.path = $util.emptyArray; + + /** + * Annotation sourceFile. + * @member {string} sourceFile + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.sourceFile = ""; + + /** + * Annotation begin. + * @member {number} begin + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.begin = 0; + + /** + * Annotation end. + * @member {number} end + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.end = 0; + + /** + * Annotation semantic. + * @member {google.protobuf.GeneratedCodeInfo.Annotation.Semantic} semantic + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + */ + Annotation.prototype.semantic = 0; + + /** + * Creates a new Annotation instance using the specified properties. + * @function create + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation=} [properties] Properties to set + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation instance + */ + Annotation.create = function create(properties) { + return new Annotation(properties); + }; + + /** + * Encodes the specified Annotation message. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.path != null && message.path.length) { + writer.uint32(/* id 1, wireType 2 =*/10).fork(); + for (var i = 0; i < message.path.length; ++i) + writer.int32(message.path[i]); + writer.ldelim(); + } + if (message.sourceFile != null && Object.hasOwnProperty.call(message, "sourceFile")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.sourceFile); + if (message.begin != null && Object.hasOwnProperty.call(message, "begin")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.begin); + if (message.end != null && Object.hasOwnProperty.call(message, "end")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.end); + if (message.semantic != null && Object.hasOwnProperty.call(message, "semantic")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.semantic); + return writer; + }; + + /** + * Encodes the specified Annotation message, length delimited. Does not implicitly {@link google.protobuf.GeneratedCodeInfo.Annotation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.IAnnotation} message Annotation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Annotation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Annotation message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.GeneratedCodeInfo.Annotation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.path && message.path.length)) + message.path = []; + if ((tag & 7) === 2) { + var end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) + message.path.push(reader.int32()); + } else + message.path.push(reader.int32()); + break; + } + case 2: { + message.sourceFile = reader.string(); + break; + } + case 3: { + message.begin = reader.int32(); + break; + } + case 4: { + message.end = reader.int32(); + break; + } + case 5: { + message.semantic = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Annotation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Annotation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Annotation message. + * @function verify + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Annotation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.path != null && message.hasOwnProperty("path")) { + if (!Array.isArray(message.path)) + return "path: array expected"; + for (var i = 0; i < message.path.length; ++i) + if (!$util.isInteger(message.path[i])) + return "path: integer[] expected"; + } + if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + if (!$util.isString(message.sourceFile)) + return "sourceFile: string expected"; + if (message.begin != null && message.hasOwnProperty("begin")) + if (!$util.isInteger(message.begin)) + return "begin: integer expected"; + if (message.end != null && message.hasOwnProperty("end")) + if (!$util.isInteger(message.end)) + return "end: integer expected"; + if (message.semantic != null && message.hasOwnProperty("semantic")) + switch (message.semantic) { + default: + return "semantic: enum value expected"; + case 0: + case 1: + case 2: + break; + } + return null; + }; + + /** + * Creates an Annotation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.GeneratedCodeInfo.Annotation} Annotation + */ + Annotation.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.GeneratedCodeInfo.Annotation) + return object; + var message = new $root.google.protobuf.GeneratedCodeInfo.Annotation(); + if (object.path) { + if (!Array.isArray(object.path)) + throw TypeError(".google.protobuf.GeneratedCodeInfo.Annotation.path: array expected"); + message.path = []; + for (var i = 0; i < object.path.length; ++i) + message.path[i] = object.path[i] | 0; + } + if (object.sourceFile != null) + message.sourceFile = String(object.sourceFile); + if (object.begin != null) + message.begin = object.begin | 0; + if (object.end != null) + message.end = object.end | 0; + switch (object.semantic) { + default: + if (typeof object.semantic === "number") { + message.semantic = object.semantic; + break; + } + break; + case "NONE": + case 0: + message.semantic = 0; + break; + case "SET": + case 1: + message.semantic = 1; + break; + case "ALIAS": + case 2: + message.semantic = 2; + break; + } + return message; + }; + + /** + * Creates a plain object from an Annotation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {google.protobuf.GeneratedCodeInfo.Annotation} message Annotation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Annotation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.path = []; + if (options.defaults) { + object.sourceFile = ""; + object.begin = 0; + object.end = 0; + object.semantic = options.enums === String ? "NONE" : 0; + } + if (message.path && message.path.length) { + object.path = []; + for (var j = 0; j < message.path.length; ++j) + object.path[j] = message.path[j]; + } + if (message.sourceFile != null && message.hasOwnProperty("sourceFile")) + object.sourceFile = message.sourceFile; + if (message.begin != null && message.hasOwnProperty("begin")) + object.begin = message.begin; + if (message.end != null && message.hasOwnProperty("end")) + object.end = message.end; + if (message.semantic != null && message.hasOwnProperty("semantic")) + object.semantic = options.enums === String ? $root.google.protobuf.GeneratedCodeInfo.Annotation.Semantic[message.semantic] === undefined ? message.semantic : $root.google.protobuf.GeneratedCodeInfo.Annotation.Semantic[message.semantic] : message.semantic; + return object; + }; + + /** + * Converts this Annotation to JSON. + * @function toJSON + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @instance + * @returns {Object.} JSON object + */ + Annotation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Annotation + * @function getTypeUrl + * @memberof google.protobuf.GeneratedCodeInfo.Annotation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Annotation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.GeneratedCodeInfo.Annotation"; + }; + + /** + * Semantic enum. + * @name google.protobuf.GeneratedCodeInfo.Annotation.Semantic + * @enum {number} + * @property {number} NONE=0 NONE value + * @property {number} SET=1 SET value + * @property {number} ALIAS=2 ALIAS value + */ + Annotation.Semantic = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NONE"] = 0; + values[valuesById[1] = "SET"] = 1; + values[valuesById[2] = "ALIAS"] = 2; + return values; + })(); + + return Annotation; + })(); + + return GeneratedCodeInfo; + })(); + + /** + * SymbolVisibility enum. + * @name google.protobuf.SymbolVisibility + * @enum {number} + * @property {number} VISIBILITY_UNSET=0 VISIBILITY_UNSET value + * @property {number} VISIBILITY_LOCAL=1 VISIBILITY_LOCAL value + * @property {number} VISIBILITY_EXPORT=2 VISIBILITY_EXPORT value + */ + protobuf.SymbolVisibility = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "VISIBILITY_UNSET"] = 0; + values[valuesById[1] = "VISIBILITY_LOCAL"] = 1; + values[valuesById[2] = "VISIBILITY_EXPORT"] = 2; + return values; + })(); + + protobuf.Duration = (function() { + + /** + * Properties of a Duration. + * @memberof google.protobuf + * @interface IDuration + * @property {number|Long|null} [seconds] Duration seconds + * @property {number|null} [nanos] Duration nanos + */ + + /** + * Constructs a new Duration. + * @memberof google.protobuf + * @classdesc Represents a Duration. + * @implements IDuration + * @constructor + * @param {google.protobuf.IDuration=} [properties] Properties to set + */ + function Duration(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Duration seconds. + * @member {number|Long} seconds + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Duration nanos. + * @member {number} nanos + * @memberof google.protobuf.Duration + * @instance + */ + Duration.prototype.nanos = 0; + + /** + * Creates a new Duration instance using the specified properties. + * @function create + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration=} [properties] Properties to set + * @returns {google.protobuf.Duration} Duration instance + */ + Duration.create = function create(properties) { + return new Duration(properties); + }; + + /** + * Encodes the specified Duration message. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration} message Duration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Duration.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); + if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); + return writer; + }; + + /** + * Encodes the specified Duration message, length delimited. Does not implicitly {@link google.protobuf.Duration.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.IDuration} message Duration message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Duration.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Duration message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Duration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Duration} Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Duration.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Duration(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.seconds = reader.int64(); + break; + } + case 2: { + message.nanos = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Duration message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Duration + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Duration} Duration + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Duration.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Duration message. + * @function verify + * @memberof google.protobuf.Duration + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Duration.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high))) + return "seconds: integer|Long expected"; + if (message.nanos != null && message.hasOwnProperty("nanos")) + if (!$util.isInteger(message.nanos)) + return "nanos: integer expected"; + return null; + }; + + /** + * Creates a Duration message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Duration + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Duration} Duration + */ + Duration.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Duration) + return object; + var message = new $root.google.protobuf.Duration(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Duration message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Duration + * @static + * @param {google.protobuf.Duration} message Duration + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Duration.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Duration to JSON. + * @function toJSON + * @memberof google.protobuf.Duration + * @instance + * @returns {Object.} JSON object + */ + Duration.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Duration + * @function getTypeUrl + * @memberof google.protobuf.Duration + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Duration.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Duration"; + }; + + return Duration; + })(); + + protobuf.Any = (function() { + + /** + * Properties of an Any. + * @memberof google.protobuf + * @interface IAny + * @property {string|null} [type_url] Any type_url + * @property {Uint8Array|null} [value] Any value + */ + + /** + * Constructs a new Any. + * @memberof google.protobuf + * @classdesc Represents an Any. + * @implements IAny + * @constructor + * @param {google.protobuf.IAny=} [properties] Properties to set + */ + function Any(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Any type_url. + * @member {string} type_url + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.type_url = ""; + + /** + * Any value. + * @member {Uint8Array} value + * @memberof google.protobuf.Any + * @instance + */ + Any.prototype.value = $util.newBuffer([]); + + /** + * Creates a new Any instance using the specified properties. + * @function create + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny=} [properties] Properties to set + * @returns {google.protobuf.Any} Any instance + */ + Any.create = function create(properties) { + return new Any(properties); + }; + + /** + * Encodes the specified Any message. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.type_url != null && Object.hasOwnProperty.call(message, "type_url")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.type_url); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 2, wireType 2 =*/18).bytes(message.value); + return writer; + }; + + /** + * Encodes the specified Any message, length delimited. Does not implicitly {@link google.protobuf.Any.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.IAny} message Any message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Any.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Any message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Any(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.type_url = reader.string(); + break; + } + case 2: { + message.value = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Any message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Any + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Any} Any + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Any.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Any message. + * @function verify + * @memberof google.protobuf.Any + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Any.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.type_url != null && message.hasOwnProperty("type_url")) + if (!$util.isString(message.type_url)) + return "type_url: string expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) + return "value: buffer expected"; + return null; + }; + + /** + * Creates an Any message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Any + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Any} Any + */ + Any.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Any) + return object; + var message = new $root.google.protobuf.Any(); + if (object.type_url != null) + message.type_url = String(object.type_url); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length >= 0) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from an Any message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Any + * @static + * @param {google.protobuf.Any} message Any + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Any.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.type_url = ""; + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + } + if (message.type_url != null && message.hasOwnProperty("type_url")) + object.type_url = message.type_url; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this Any to JSON. + * @function toJSON + * @memberof google.protobuf.Any + * @instance + * @returns {Object.} JSON object + */ + Any.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Any + * @function getTypeUrl + * @memberof google.protobuf.Any + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Any.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Any"; + }; + + return Any; + })(); + + protobuf.Empty = (function() { + + /** + * Properties of an Empty. + * @memberof google.protobuf + * @interface IEmpty + */ + + /** + * Constructs a new Empty. + * @memberof google.protobuf + * @classdesc Represents an Empty. + * @implements IEmpty + * @constructor + * @param {google.protobuf.IEmpty=} [properties] Properties to set + */ + function Empty(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Creates a new Empty instance using the specified properties. + * @function create + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty=} [properties] Properties to set + * @returns {google.protobuf.Empty} Empty instance + */ + Empty.create = function create(properties) { + return new Empty(properties); + }; + + /** + * Encodes the specified Empty message. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + return writer; + }; + + /** + * Encodes the specified Empty message, length delimited. Does not implicitly {@link google.protobuf.Empty.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.IEmpty} message Empty message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Empty.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Empty message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Empty(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Empty message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Empty + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Empty} Empty + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Empty.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Empty message. + * @function verify + * @memberof google.protobuf.Empty + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Empty.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + return null; + }; + + /** + * Creates an Empty message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Empty + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Empty} Empty + */ + Empty.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Empty) + return object; + return new $root.google.protobuf.Empty(); + }; + + /** + * Creates a plain object from an Empty message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Empty + * @static + * @param {google.protobuf.Empty} message Empty + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Empty.toObject = function toObject() { + return {}; + }; + + /** + * Converts this Empty to JSON. + * @function toJSON + * @memberof google.protobuf.Empty + * @instance + * @returns {Object.} JSON object + */ + Empty.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Empty + * @function getTypeUrl + * @memberof google.protobuf.Empty + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Empty.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Empty"; + }; + + return Empty; + })(); + + protobuf.Timestamp = (function() { + + /** + * Properties of a Timestamp. + * @memberof google.protobuf + * @interface ITimestamp + * @property {number|Long|null} [seconds] Timestamp seconds + * @property {number|null} [nanos] Timestamp nanos + */ + + /** + * Constructs a new Timestamp. + * @memberof google.protobuf + * @classdesc Represents a Timestamp. + * @implements ITimestamp + * @constructor + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + */ + function Timestamp(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Timestamp seconds. + * @member {number|Long} seconds + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.seconds = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Timestamp nanos. + * @member {number} nanos + * @memberof google.protobuf.Timestamp + * @instance + */ + Timestamp.prototype.nanos = 0; + + /** + * Creates a new Timestamp instance using the specified properties. + * @function create + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp=} [properties] Properties to set + * @returns {google.protobuf.Timestamp} Timestamp instance + */ + Timestamp.create = function create(properties) { + return new Timestamp(properties); + }; + + /** + * Encodes the specified Timestamp message. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.seconds != null && Object.hasOwnProperty.call(message, "seconds")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.seconds); + if (message.nanos != null && Object.hasOwnProperty.call(message, "nanos")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.nanos); + return writer; + }; + + /** + * Encodes the specified Timestamp message, length delimited. Does not implicitly {@link google.protobuf.Timestamp.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.ITimestamp} message Timestamp message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Timestamp.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Timestamp message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Timestamp(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.seconds = reader.int64(); + break; + } + case 2: { + message.nanos = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Timestamp message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Timestamp + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Timestamp} Timestamp + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Timestamp.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Timestamp message. + * @function verify + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Timestamp.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (!$util.isInteger(message.seconds) && !(message.seconds && $util.isInteger(message.seconds.low) && $util.isInteger(message.seconds.high))) + return "seconds: integer|Long expected"; + if (message.nanos != null && message.hasOwnProperty("nanos")) + if (!$util.isInteger(message.nanos)) + return "nanos: integer expected"; + return null; + }; + + /** + * Creates a Timestamp message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Timestamp + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Timestamp} Timestamp + */ + Timestamp.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Timestamp) + return object; + var message = new $root.google.protobuf.Timestamp(); + if (object.seconds != null) + if ($util.Long) + (message.seconds = $util.Long.fromValue(object.seconds)).unsigned = false; + else if (typeof object.seconds === "string") + message.seconds = parseInt(object.seconds, 10); + else if (typeof object.seconds === "number") + message.seconds = object.seconds; + else if (typeof object.seconds === "object") + message.seconds = new $util.LongBits(object.seconds.low >>> 0, object.seconds.high >>> 0).toNumber(); + if (object.nanos != null) + message.nanos = object.nanos | 0; + return message; + }; + + /** + * Creates a plain object from a Timestamp message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Timestamp + * @static + * @param {google.protobuf.Timestamp} message Timestamp + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Timestamp.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.seconds = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.seconds = options.longs === String ? "0" : 0; + object.nanos = 0; + } + if (message.seconds != null && message.hasOwnProperty("seconds")) + if (typeof message.seconds === "number") + object.seconds = options.longs === String ? String(message.seconds) : message.seconds; + else + object.seconds = options.longs === String ? $util.Long.prototype.toString.call(message.seconds) : options.longs === Number ? new $util.LongBits(message.seconds.low >>> 0, message.seconds.high >>> 0).toNumber() : message.seconds; + if (message.nanos != null && message.hasOwnProperty("nanos")) + object.nanos = message.nanos; + return object; + }; + + /** + * Converts this Timestamp to JSON. + * @function toJSON + * @memberof google.protobuf.Timestamp + * @instance + * @returns {Object.} JSON object + */ + Timestamp.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Timestamp + * @function getTypeUrl + * @memberof google.protobuf.Timestamp + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Timestamp.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Timestamp"; + }; + + return Timestamp; + })(); + + protobuf.Struct = (function() { + + /** + * Properties of a Struct. + * @memberof google.protobuf + * @interface IStruct + * @property {Object.|null} [fields] Struct fields + */ + + /** + * Constructs a new Struct. + * @memberof google.protobuf + * @classdesc Represents a Struct. + * @implements IStruct + * @constructor + * @param {google.protobuf.IStruct=} [properties] Properties to set + */ + function Struct(properties) { + this.fields = {}; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Struct fields. + * @member {Object.} fields + * @memberof google.protobuf.Struct + * @instance + */ + Struct.prototype.fields = $util.emptyObject; + + /** + * Creates a new Struct instance using the specified properties. + * @function create + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct=} [properties] Properties to set + * @returns {google.protobuf.Struct} Struct instance + */ + Struct.create = function create(properties) { + return new Struct(properties); + }; + + /** + * Encodes the specified Struct message. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct} message Struct message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Struct.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.fields != null && Object.hasOwnProperty.call(message, "fields")) + for (var keys = Object.keys(message.fields), i = 0; i < keys.length; ++i) { + writer.uint32(/* id 1, wireType 2 =*/10).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); + $root.google.protobuf.Value.encode(message.fields[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); + } + return writer; + }; + + /** + * Encodes the specified Struct message, length delimited. Does not implicitly {@link google.protobuf.Struct.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.IStruct} message Struct message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Struct.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Struct message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Struct + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Struct} Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Struct.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Struct(), key, value; + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (message.fields === $util.emptyObject) + message.fields = {}; + var end2 = reader.uint32() + reader.pos; + key = ""; + value = null; + while (reader.pos < end2) { + var tag2 = reader.uint32(); + switch (tag2 >>> 3) { + case 1: + key = reader.string(); + break; + case 2: + value = $root.google.protobuf.Value.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag2 & 7); + break; + } + } + message.fields[key] = value; + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Struct message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Struct + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Struct} Struct + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Struct.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Struct message. + * @function verify + * @memberof google.protobuf.Struct + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Struct.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.fields != null && message.hasOwnProperty("fields")) { + if (!$util.isObject(message.fields)) + return "fields: object expected"; + var key = Object.keys(message.fields); + for (var i = 0; i < key.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.fields[key[i]]); + if (error) + return "fields." + error; + } + } + return null; + }; + + /** + * Creates a Struct message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Struct + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Struct} Struct + */ + Struct.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Struct) + return object; + var message = new $root.google.protobuf.Struct(); + if (object.fields) { + if (typeof object.fields !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields = {}; + for (var keys = Object.keys(object.fields), i = 0; i < keys.length; ++i) { + if (typeof object.fields[keys[i]] !== "object") + throw TypeError(".google.protobuf.Struct.fields: object expected"); + message.fields[keys[i]] = $root.google.protobuf.Value.fromObject(object.fields[keys[i]]); + } + } + return message; + }; + + /** + * Creates a plain object from a Struct message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Struct + * @static + * @param {google.protobuf.Struct} message Struct + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Struct.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.objects || options.defaults) + object.fields = {}; + var keys2; + if (message.fields && (keys2 = Object.keys(message.fields)).length) { + object.fields = {}; + for (var j = 0; j < keys2.length; ++j) + object.fields[keys2[j]] = $root.google.protobuf.Value.toObject(message.fields[keys2[j]], options); + } + return object; + }; + + /** + * Converts this Struct to JSON. + * @function toJSON + * @memberof google.protobuf.Struct + * @instance + * @returns {Object.} JSON object + */ + Struct.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Struct + * @function getTypeUrl + * @memberof google.protobuf.Struct + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Struct.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Struct"; + }; + + return Struct; + })(); + + protobuf.Value = (function() { + + /** + * Properties of a Value. + * @memberof google.protobuf + * @interface IValue + * @property {google.protobuf.NullValue|null} [nullValue] Value nullValue + * @property {number|null} [numberValue] Value numberValue + * @property {string|null} [stringValue] Value stringValue + * @property {boolean|null} [boolValue] Value boolValue + * @property {google.protobuf.IStruct|null} [structValue] Value structValue + * @property {google.protobuf.IListValue|null} [listValue] Value listValue + */ + + /** + * Constructs a new Value. + * @memberof google.protobuf + * @classdesc Represents a Value. + * @implements IValue + * @constructor + * @param {google.protobuf.IValue=} [properties] Properties to set + */ + function Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Value nullValue. + * @member {google.protobuf.NullValue|null|undefined} nullValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.nullValue = null; + + /** + * Value numberValue. + * @member {number|null|undefined} numberValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.numberValue = null; + + /** + * Value stringValue. + * @member {string|null|undefined} stringValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.stringValue = null; + + /** + * Value boolValue. + * @member {boolean|null|undefined} boolValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.boolValue = null; + + /** + * Value structValue. + * @member {google.protobuf.IStruct|null|undefined} structValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.structValue = null; + + /** + * Value listValue. + * @member {google.protobuf.IListValue|null|undefined} listValue + * @memberof google.protobuf.Value + * @instance + */ + Value.prototype.listValue = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Value kind. + * @member {"nullValue"|"numberValue"|"stringValue"|"boolValue"|"structValue"|"listValue"|undefined} kind + * @memberof google.protobuf.Value + * @instance + */ + Object.defineProperty(Value.prototype, "kind", { + get: $util.oneOfGetter($oneOfFields = ["nullValue", "numberValue", "stringValue", "boolValue", "structValue", "listValue"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Value instance using the specified properties. + * @function create + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue=} [properties] Properties to set + * @returns {google.protobuf.Value} Value instance + */ + Value.create = function create(properties) { + return new Value(properties); + }; + + /** + * Encodes the specified Value message. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.nullValue != null && Object.hasOwnProperty.call(message, "nullValue")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.nullValue); + if (message.numberValue != null && Object.hasOwnProperty.call(message, "numberValue")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.numberValue); + if (message.stringValue != null && Object.hasOwnProperty.call(message, "stringValue")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.stringValue); + if (message.boolValue != null && Object.hasOwnProperty.call(message, "boolValue")) + writer.uint32(/* id 4, wireType 0 =*/32).bool(message.boolValue); + if (message.structValue != null && Object.hasOwnProperty.call(message, "structValue")) + $root.google.protobuf.Struct.encode(message.structValue, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.listValue != null && Object.hasOwnProperty.call(message, "listValue")) + $root.google.protobuf.ListValue.encode(message.listValue, writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Value message, length delimited. Does not implicitly {@link google.protobuf.Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.IValue} message Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.nullValue = reader.int32(); + break; + } + case 2: { + message.numberValue = reader.double(); + break; + } + case 3: { + message.stringValue = reader.string(); + break; + } + case 4: { + message.boolValue = reader.bool(); + break; + } + case 5: { + message.structValue = $root.google.protobuf.Struct.decode(reader, reader.uint32()); + break; + } + case 6: { + message.listValue = $root.google.protobuf.ListValue.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Value} Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Value message. + * @function verify + * @memberof google.protobuf.Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + properties.kind = 1; + switch (message.nullValue) { + default: + return "nullValue: enum value expected"; + case 0: + break; + } + } + if (message.numberValue != null && message.hasOwnProperty("numberValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + if (typeof message.numberValue !== "number") + return "numberValue: number expected"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + if (!$util.isString(message.stringValue)) + return "stringValue: string expected"; + } + if (message.boolValue != null && message.hasOwnProperty("boolValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + if (typeof message.boolValue !== "boolean") + return "boolValue: boolean expected"; + } + if (message.structValue != null && message.hasOwnProperty("structValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + { + var error = $root.google.protobuf.Struct.verify(message.structValue); + if (error) + return "structValue." + error; + } + } + if (message.listValue != null && message.hasOwnProperty("listValue")) { + if (properties.kind === 1) + return "kind: multiple values"; + properties.kind = 1; + { + var error = $root.google.protobuf.ListValue.verify(message.listValue); + if (error) + return "listValue." + error; + } + } + return null; + }; + + /** + * Creates a Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Value} Value + */ + Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Value) + return object; + var message = new $root.google.protobuf.Value(); + switch (object.nullValue) { + default: + if (typeof object.nullValue === "number") { + message.nullValue = object.nullValue; + break; + } + break; + case "NULL_VALUE": + case 0: + message.nullValue = 0; + break; + } + if (object.numberValue != null) + message.numberValue = Number(object.numberValue); + if (object.stringValue != null) + message.stringValue = String(object.stringValue); + if (object.boolValue != null) + message.boolValue = Boolean(object.boolValue); + if (object.structValue != null) { + if (typeof object.structValue !== "object") + throw TypeError(".google.protobuf.Value.structValue: object expected"); + message.structValue = $root.google.protobuf.Struct.fromObject(object.structValue); + } + if (object.listValue != null) { + if (typeof object.listValue !== "object") + throw TypeError(".google.protobuf.Value.listValue: object expected"); + message.listValue = $root.google.protobuf.ListValue.fromObject(object.listValue); + } + return message; + }; + + /** + * Creates a plain object from a Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Value + * @static + * @param {google.protobuf.Value} message Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (message.nullValue != null && message.hasOwnProperty("nullValue")) { + object.nullValue = options.enums === String ? $root.google.protobuf.NullValue[message.nullValue] === undefined ? message.nullValue : $root.google.protobuf.NullValue[message.nullValue] : message.nullValue; + if (options.oneofs) + object.kind = "nullValue"; + } + if (message.numberValue != null && message.hasOwnProperty("numberValue")) { + object.numberValue = options.json && !isFinite(message.numberValue) ? String(message.numberValue) : message.numberValue; + if (options.oneofs) + object.kind = "numberValue"; + } + if (message.stringValue != null && message.hasOwnProperty("stringValue")) { + object.stringValue = message.stringValue; + if (options.oneofs) + object.kind = "stringValue"; + } + if (message.boolValue != null && message.hasOwnProperty("boolValue")) { + object.boolValue = message.boolValue; + if (options.oneofs) + object.kind = "boolValue"; + } + if (message.structValue != null && message.hasOwnProperty("structValue")) { + object.structValue = $root.google.protobuf.Struct.toObject(message.structValue, options); + if (options.oneofs) + object.kind = "structValue"; + } + if (message.listValue != null && message.hasOwnProperty("listValue")) { + object.listValue = $root.google.protobuf.ListValue.toObject(message.listValue, options); + if (options.oneofs) + object.kind = "listValue"; + } + return object; + }; + + /** + * Converts this Value to JSON. + * @function toJSON + * @memberof google.protobuf.Value + * @instance + * @returns {Object.} JSON object + */ + Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Value + * @function getTypeUrl + * @memberof google.protobuf.Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Value"; + }; + + return Value; + })(); + + /** + * NullValue enum. + * @name google.protobuf.NullValue + * @enum {number} + * @property {number} NULL_VALUE=0 NULL_VALUE value + */ + protobuf.NullValue = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "NULL_VALUE"] = 0; + return values; + })(); + + protobuf.ListValue = (function() { + + /** + * Properties of a ListValue. + * @memberof google.protobuf + * @interface IListValue + * @property {Array.|null} [values] ListValue values + */ + + /** + * Constructs a new ListValue. + * @memberof google.protobuf + * @classdesc Represents a ListValue. + * @implements IListValue + * @constructor + * @param {google.protobuf.IListValue=} [properties] Properties to set + */ + function ListValue(properties) { + this.values = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListValue values. + * @member {Array.} values + * @memberof google.protobuf.ListValue + * @instance + */ + ListValue.prototype.values = $util.emptyArray; + + /** + * Creates a new ListValue instance using the specified properties. + * @function create + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue=} [properties] Properties to set + * @returns {google.protobuf.ListValue} ListValue instance + */ + ListValue.create = function create(properties) { + return new ListValue(properties); + }; + + /** + * Encodes the specified ListValue message. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue} message ListValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.values != null && message.values.length) + for (var i = 0; i < message.values.length; ++i) + $root.google.protobuf.Value.encode(message.values[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ListValue message, length delimited. Does not implicitly {@link google.protobuf.ListValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.IListValue} message ListValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.ListValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.ListValue} ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.ListValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.values && message.values.length)) + message.values = []; + message.values.push($root.google.protobuf.Value.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.ListValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.ListValue} ListValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListValue message. + * @function verify + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.values != null && message.hasOwnProperty("values")) { + if (!Array.isArray(message.values)) + return "values: array expected"; + for (var i = 0; i < message.values.length; ++i) { + var error = $root.google.protobuf.Value.verify(message.values[i]); + if (error) + return "values." + error; + } + } + return null; + }; + + /** + * Creates a ListValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.ListValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.ListValue} ListValue + */ + ListValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.ListValue) + return object; + var message = new $root.google.protobuf.ListValue(); + if (object.values) { + if (!Array.isArray(object.values)) + throw TypeError(".google.protobuf.ListValue.values: array expected"); + message.values = []; + for (var i = 0; i < object.values.length; ++i) { + if (typeof object.values[i] !== "object") + throw TypeError(".google.protobuf.ListValue.values: object expected"); + message.values[i] = $root.google.protobuf.Value.fromObject(object.values[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a ListValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.ListValue + * @static + * @param {google.protobuf.ListValue} message ListValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.values = []; + if (message.values && message.values.length) { + object.values = []; + for (var j = 0; j < message.values.length; ++j) + object.values[j] = $root.google.protobuf.Value.toObject(message.values[j], options); + } + return object; + }; + + /** + * Converts this ListValue to JSON. + * @function toJSON + * @memberof google.protobuf.ListValue + * @instance + * @returns {Object.} JSON object + */ + ListValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListValue + * @function getTypeUrl + * @memberof google.protobuf.ListValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.ListValue"; + }; + + return ListValue; + })(); + + protobuf.DoubleValue = (function() { + + /** + * Properties of a DoubleValue. + * @memberof google.protobuf + * @interface IDoubleValue + * @property {number|null} [value] DoubleValue value + */ + + /** + * Constructs a new DoubleValue. + * @memberof google.protobuf + * @classdesc Represents a DoubleValue. + * @implements IDoubleValue + * @constructor + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set + */ + function DoubleValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DoubleValue value. + * @member {number} value + * @memberof google.protobuf.DoubleValue + * @instance + */ + DoubleValue.prototype.value = 0; + + /** + * Creates a new DoubleValue instance using the specified properties. + * @function create + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.IDoubleValue=} [properties] Properties to set + * @returns {google.protobuf.DoubleValue} DoubleValue instance + */ + DoubleValue.create = function create(properties) { + return new DoubleValue(properties); + }; + + /** + * Encodes the specified DoubleValue message. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.IDoubleValue} message DoubleValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoubleValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.value); + return writer; + }; + + /** + * Encodes the specified DoubleValue message, length delimited. Does not implicitly {@link google.protobuf.DoubleValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.IDoubleValue} message DoubleValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DoubleValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DoubleValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.DoubleValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.DoubleValue} DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoubleValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.DoubleValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DoubleValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.DoubleValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.DoubleValue} DoubleValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DoubleValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DoubleValue message. + * @function verify + * @memberof google.protobuf.DoubleValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DoubleValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value !== "number") + return "value: number expected"; + return null; + }; + + /** + * Creates a DoubleValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.DoubleValue} DoubleValue + */ + DoubleValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.DoubleValue) + return object; + var message = new $root.google.protobuf.DoubleValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a DoubleValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.DoubleValue + * @static + * @param {google.protobuf.DoubleValue} message DoubleValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DoubleValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this DoubleValue to JSON. + * @function toJSON + * @memberof google.protobuf.DoubleValue + * @instance + * @returns {Object.} JSON object + */ + DoubleValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DoubleValue + * @function getTypeUrl + * @memberof google.protobuf.DoubleValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DoubleValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.DoubleValue"; + }; + + return DoubleValue; + })(); + + protobuf.FloatValue = (function() { + + /** + * Properties of a FloatValue. + * @memberof google.protobuf + * @interface IFloatValue + * @property {number|null} [value] FloatValue value + */ + + /** + * Constructs a new FloatValue. + * @memberof google.protobuf + * @classdesc Represents a FloatValue. + * @implements IFloatValue + * @constructor + * @param {google.protobuf.IFloatValue=} [properties] Properties to set + */ + function FloatValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * FloatValue value. + * @member {number} value + * @memberof google.protobuf.FloatValue + * @instance + */ + FloatValue.prototype.value = 0; + + /** + * Creates a new FloatValue instance using the specified properties. + * @function create + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.IFloatValue=} [properties] Properties to set + * @returns {google.protobuf.FloatValue} FloatValue instance + */ + FloatValue.create = function create(properties) { + return new FloatValue(properties); + }; + + /** + * Encodes the specified FloatValue message. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.IFloatValue} message FloatValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FloatValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 5 =*/13).float(message.value); + return writer; + }; + + /** + * Encodes the specified FloatValue message, length delimited. Does not implicitly {@link google.protobuf.FloatValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.IFloatValue} message FloatValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + FloatValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a FloatValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.FloatValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.FloatValue} FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FloatValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.FloatValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.float(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a FloatValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.FloatValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.FloatValue} FloatValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + FloatValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a FloatValue message. + * @function verify + * @memberof google.protobuf.FloatValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + FloatValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value !== "number") + return "value: number expected"; + return null; + }; + + /** + * Creates a FloatValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.FloatValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.FloatValue} FloatValue + */ + FloatValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.FloatValue) + return object; + var message = new $root.google.protobuf.FloatValue(); + if (object.value != null) + message.value = Number(object.value); + return message; + }; + + /** + * Creates a plain object from a FloatValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.FloatValue + * @static + * @param {google.protobuf.FloatValue} message FloatValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + FloatValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.json && !isFinite(message.value) ? String(message.value) : message.value; + return object; + }; + + /** + * Converts this FloatValue to JSON. + * @function toJSON + * @memberof google.protobuf.FloatValue + * @instance + * @returns {Object.} JSON object + */ + FloatValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for FloatValue + * @function getTypeUrl + * @memberof google.protobuf.FloatValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + FloatValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.FloatValue"; + }; + + return FloatValue; + })(); + + protobuf.Int64Value = (function() { + + /** + * Properties of an Int64Value. + * @memberof google.protobuf + * @interface IInt64Value + * @property {number|Long|null} [value] Int64Value value + */ + + /** + * Constructs a new Int64Value. + * @memberof google.protobuf + * @classdesc Represents an Int64Value. + * @implements IInt64Value + * @constructor + * @param {google.protobuf.IInt64Value=} [properties] Properties to set + */ + function Int64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int64Value value. + * @member {number|Long} value + * @memberof google.protobuf.Int64Value + * @instance + */ + Int64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,false) : 0; + + /** + * Creates a new Int64Value instance using the specified properties. + * @function create + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.IInt64Value=} [properties] Properties to set + * @returns {google.protobuf.Int64Value} Int64Value instance + */ + Int64Value.create = function create(properties) { + return new Int64Value(properties); + }; + + /** + * Encodes the specified Int64Value message. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.IInt64Value} message Int64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int64Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 0 =*/8).int64(message.value); + return writer; + }; + + /** + * Encodes the specified Int64Value message, length delimited. Does not implicitly {@link google.protobuf.Int64Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.IInt64Value} message Int64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int64Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Int64Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Int64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Int64Value} Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int64Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Int64Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.int64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Int64Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Int64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Int64Value} Int64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int64Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Int64Value message. + * @function verify + * @memberof google.protobuf.Int64Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Int64Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) + return "value: integer|Long expected"; + return null; + }; + + /** + * Creates an Int64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int64Value} Int64Value + */ + Int64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int64Value) + return object; + var message = new $root.google.protobuf.Int64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = false; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(); + return message; + }; + + /** + * Creates a plain object from an Int64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int64Value + * @static + * @param {google.protobuf.Int64Value} message Int64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, false); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber() : message.value; + return object; + }; + + /** + * Converts this Int64Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int64Value + * @instance + * @returns {Object.} JSON object + */ + Int64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Int64Value + * @function getTypeUrl + * @memberof google.protobuf.Int64Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Int64Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Int64Value"; + }; + + return Int64Value; + })(); + + protobuf.UInt64Value = (function() { + + /** + * Properties of a UInt64Value. + * @memberof google.protobuf + * @interface IUInt64Value + * @property {number|Long|null} [value] UInt64Value value + */ + + /** + * Constructs a new UInt64Value. + * @memberof google.protobuf + * @classdesc Represents a UInt64Value. + * @implements IUInt64Value + * @constructor + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set + */ + function UInt64Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt64Value value. + * @member {number|Long} value + * @memberof google.protobuf.UInt64Value + * @instance + */ + UInt64Value.prototype.value = $util.Long ? $util.Long.fromBits(0,0,true) : 0; + + /** + * Creates a new UInt64Value instance using the specified properties. + * @function create + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.IUInt64Value=} [properties] Properties to set + * @returns {google.protobuf.UInt64Value} UInt64Value instance + */ + UInt64Value.create = function create(properties) { + return new UInt64Value(properties); + }; + + /** + * Encodes the specified UInt64Value message. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.IUInt64Value} message UInt64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt64Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 0 =*/8).uint64(message.value); + return writer; + }; + + /** + * Encodes the specified UInt64Value message, length delimited. Does not implicitly {@link google.protobuf.UInt64Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.IUInt64Value} message UInt64Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt64Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UInt64Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UInt64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UInt64Value} UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt64Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UInt64Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.uint64(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UInt64Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UInt64Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UInt64Value} UInt64Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt64Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UInt64Value message. + * @function verify + * @memberof google.protobuf.UInt64Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UInt64Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value) && !(message.value && $util.isInteger(message.value.low) && $util.isInteger(message.value.high))) + return "value: integer|Long expected"; + return null; + }; + + /** + * Creates a UInt64Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt64Value} UInt64Value + */ + UInt64Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt64Value) + return object; + var message = new $root.google.protobuf.UInt64Value(); + if (object.value != null) + if ($util.Long) + (message.value = $util.Long.fromValue(object.value)).unsigned = true; + else if (typeof object.value === "string") + message.value = parseInt(object.value, 10); + else if (typeof object.value === "number") + message.value = object.value; + else if (typeof object.value === "object") + message.value = new $util.LongBits(object.value.low >>> 0, object.value.high >>> 0).toNumber(true); + return message; + }; + + /** + * Creates a plain object from a UInt64Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt64Value + * @static + * @param {google.protobuf.UInt64Value} message UInt64Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt64Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if ($util.Long) { + var long = new $util.Long(0, 0, true); + object.value = options.longs === String ? long.toString() : options.longs === Number ? long.toNumber() : long; + } else + object.value = options.longs === String ? "0" : 0; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value === "number") + object.value = options.longs === String ? String(message.value) : message.value; + else + object.value = options.longs === String ? $util.Long.prototype.toString.call(message.value) : options.longs === Number ? new $util.LongBits(message.value.low >>> 0, message.value.high >>> 0).toNumber(true) : message.value; + return object; + }; + + /** + * Converts this UInt64Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt64Value + * @instance + * @returns {Object.} JSON object + */ + UInt64Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UInt64Value + * @function getTypeUrl + * @memberof google.protobuf.UInt64Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UInt64Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UInt64Value"; + }; + + return UInt64Value; + })(); + + protobuf.Int32Value = (function() { + + /** + * Properties of an Int32Value. + * @memberof google.protobuf + * @interface IInt32Value + * @property {number|null} [value] Int32Value value + */ + + /** + * Constructs a new Int32Value. + * @memberof google.protobuf + * @classdesc Represents an Int32Value. + * @implements IInt32Value + * @constructor + * @param {google.protobuf.IInt32Value=} [properties] Properties to set + */ + function Int32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Int32Value value. + * @member {number} value + * @memberof google.protobuf.Int32Value + * @instance + */ + Int32Value.prototype.value = 0; + + /** + * Creates a new Int32Value instance using the specified properties. + * @function create + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.IInt32Value=} [properties] Properties to set + * @returns {google.protobuf.Int32Value} Int32Value instance + */ + Int32Value.create = function create(properties) { + return new Int32Value(properties); + }; + + /** + * Encodes the specified Int32Value message. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.IInt32Value} message Int32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int32Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.value); + return writer; + }; + + /** + * Encodes the specified Int32Value message, length delimited. Does not implicitly {@link google.protobuf.Int32Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.IInt32Value} message Int32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Int32Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Int32Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.Int32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.Int32Value} Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int32Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.Int32Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.int32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Int32Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.Int32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.Int32Value} Int32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Int32Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Int32Value message. + * @function verify + * @memberof google.protobuf.Int32Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Int32Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value)) + return "value: integer expected"; + return null; + }; + + /** + * Creates an Int32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.Int32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.Int32Value} Int32Value + */ + Int32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.Int32Value) + return object; + var message = new $root.google.protobuf.Int32Value(); + if (object.value != null) + message.value = object.value | 0; + return message; + }; + + /** + * Creates a plain object from an Int32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.Int32Value + * @static + * @param {google.protobuf.Int32Value} message Int32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Int32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this Int32Value to JSON. + * @function toJSON + * @memberof google.protobuf.Int32Value + * @instance + * @returns {Object.} JSON object + */ + Int32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Int32Value + * @function getTypeUrl + * @memberof google.protobuf.Int32Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Int32Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.Int32Value"; + }; + + return Int32Value; + })(); + + protobuf.UInt32Value = (function() { + + /** + * Properties of a UInt32Value. + * @memberof google.protobuf + * @interface IUInt32Value + * @property {number|null} [value] UInt32Value value + */ + + /** + * Constructs a new UInt32Value. + * @memberof google.protobuf + * @classdesc Represents a UInt32Value. + * @implements IUInt32Value + * @constructor + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set + */ + function UInt32Value(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UInt32Value value. + * @member {number} value + * @memberof google.protobuf.UInt32Value + * @instance + */ + UInt32Value.prototype.value = 0; + + /** + * Creates a new UInt32Value instance using the specified properties. + * @function create + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.IUInt32Value=} [properties] Properties to set + * @returns {google.protobuf.UInt32Value} UInt32Value instance + */ + UInt32Value.create = function create(properties) { + return new UInt32Value(properties); + }; + + /** + * Encodes the specified UInt32Value message. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @function encode + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.IUInt32Value} message UInt32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt32Value.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 0 =*/8).uint32(message.value); + return writer; + }; + + /** + * Encodes the specified UInt32Value message, length delimited. Does not implicitly {@link google.protobuf.UInt32Value.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.IUInt32Value} message UInt32Value message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UInt32Value.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a UInt32Value message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.UInt32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.UInt32Value} UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt32Value.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.UInt32Value(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.uint32(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a UInt32Value message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.UInt32Value + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.UInt32Value} UInt32Value + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UInt32Value.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a UInt32Value message. + * @function verify + * @memberof google.protobuf.UInt32Value + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UInt32Value.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isInteger(message.value)) + return "value: integer expected"; + return null; + }; + + /** + * Creates a UInt32Value message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.UInt32Value} UInt32Value + */ + UInt32Value.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.UInt32Value) + return object; + var message = new $root.google.protobuf.UInt32Value(); + if (object.value != null) + message.value = object.value >>> 0; + return message; + }; + + /** + * Creates a plain object from a UInt32Value message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.UInt32Value + * @static + * @param {google.protobuf.UInt32Value} message UInt32Value + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UInt32Value.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = 0; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this UInt32Value to JSON. + * @function toJSON + * @memberof google.protobuf.UInt32Value + * @instance + * @returns {Object.} JSON object + */ + UInt32Value.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UInt32Value + * @function getTypeUrl + * @memberof google.protobuf.UInt32Value + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UInt32Value.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.UInt32Value"; + }; + + return UInt32Value; + })(); + + protobuf.BoolValue = (function() { + + /** + * Properties of a BoolValue. + * @memberof google.protobuf + * @interface IBoolValue + * @property {boolean|null} [value] BoolValue value + */ + + /** + * Constructs a new BoolValue. + * @memberof google.protobuf + * @classdesc Represents a BoolValue. + * @implements IBoolValue + * @constructor + * @param {google.protobuf.IBoolValue=} [properties] Properties to set + */ + function BoolValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BoolValue value. + * @member {boolean} value + * @memberof google.protobuf.BoolValue + * @instance + */ + BoolValue.prototype.value = false; + + /** + * Creates a new BoolValue instance using the specified properties. + * @function create + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.IBoolValue=} [properties] Properties to set + * @returns {google.protobuf.BoolValue} BoolValue instance + */ + BoolValue.create = function create(properties) { + return new BoolValue(properties); + }; + + /** + * Encodes the specified BoolValue message. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.IBoolValue} message BoolValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoolValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.value); + return writer; + }; + + /** + * Encodes the specified BoolValue message, length delimited. Does not implicitly {@link google.protobuf.BoolValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.IBoolValue} message BoolValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BoolValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BoolValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.BoolValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.BoolValue} BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoolValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.BoolValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.bool(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BoolValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.BoolValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.BoolValue} BoolValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BoolValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BoolValue message. + * @function verify + * @memberof google.protobuf.BoolValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BoolValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (typeof message.value !== "boolean") + return "value: boolean expected"; + return null; + }; + + /** + * Creates a BoolValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BoolValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BoolValue} BoolValue + */ + BoolValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BoolValue) + return object; + var message = new $root.google.protobuf.BoolValue(); + if (object.value != null) + message.value = Boolean(object.value); + return message; + }; + + /** + * Creates a plain object from a BoolValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BoolValue + * @static + * @param {google.protobuf.BoolValue} message BoolValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BoolValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = false; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this BoolValue to JSON. + * @function toJSON + * @memberof google.protobuf.BoolValue + * @instance + * @returns {Object.} JSON object + */ + BoolValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BoolValue + * @function getTypeUrl + * @memberof google.protobuf.BoolValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BoolValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.BoolValue"; + }; + + return BoolValue; + })(); + + protobuf.StringValue = (function() { + + /** + * Properties of a StringValue. + * @memberof google.protobuf + * @interface IStringValue + * @property {string|null} [value] StringValue value + */ + + /** + * Constructs a new StringValue. + * @memberof google.protobuf + * @classdesc Represents a StringValue. + * @implements IStringValue + * @constructor + * @param {google.protobuf.IStringValue=} [properties] Properties to set + */ + function StringValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * StringValue value. + * @member {string} value + * @memberof google.protobuf.StringValue + * @instance + */ + StringValue.prototype.value = ""; + + /** + * Creates a new StringValue instance using the specified properties. + * @function create + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.IStringValue=} [properties] Properties to set + * @returns {google.protobuf.StringValue} StringValue instance + */ + StringValue.create = function create(properties) { + return new StringValue(properties); + }; + + /** + * Encodes the specified StringValue message. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.IStringValue} message StringValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StringValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.value); + return writer; + }; + + /** + * Encodes the specified StringValue message, length delimited. Does not implicitly {@link google.protobuf.StringValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.IStringValue} message StringValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + StringValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a StringValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.StringValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.StringValue} StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StringValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.StringValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a StringValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.StringValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.StringValue} StringValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + StringValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a StringValue message. + * @function verify + * @memberof google.protobuf.StringValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + StringValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!$util.isString(message.value)) + return "value: string expected"; + return null; + }; + + /** + * Creates a StringValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.StringValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.StringValue} StringValue + */ + StringValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.StringValue) + return object; + var message = new $root.google.protobuf.StringValue(); + if (object.value != null) + message.value = String(object.value); + return message; + }; + + /** + * Creates a plain object from a StringValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.StringValue + * @static + * @param {google.protobuf.StringValue} message StringValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + StringValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.value = ""; + if (message.value != null && message.hasOwnProperty("value")) + object.value = message.value; + return object; + }; + + /** + * Converts this StringValue to JSON. + * @function toJSON + * @memberof google.protobuf.StringValue + * @instance + * @returns {Object.} JSON object + */ + StringValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for StringValue + * @function getTypeUrl + * @memberof google.protobuf.StringValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + StringValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.StringValue"; + }; + + return StringValue; + })(); + + protobuf.BytesValue = (function() { + + /** + * Properties of a BytesValue. + * @memberof google.protobuf + * @interface IBytesValue + * @property {Uint8Array|null} [value] BytesValue value + */ + + /** + * Constructs a new BytesValue. + * @memberof google.protobuf + * @classdesc Represents a BytesValue. + * @implements IBytesValue + * @constructor + * @param {google.protobuf.IBytesValue=} [properties] Properties to set + */ + function BytesValue(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BytesValue value. + * @member {Uint8Array} value + * @memberof google.protobuf.BytesValue + * @instance + */ + BytesValue.prototype.value = $util.newBuffer([]); + + /** + * Creates a new BytesValue instance using the specified properties. + * @function create + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.IBytesValue=} [properties] Properties to set + * @returns {google.protobuf.BytesValue} BytesValue instance + */ + BytesValue.create = function create(properties) { + return new BytesValue(properties); + }; + + /** + * Encodes the specified BytesValue message. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @function encode + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.IBytesValue} message BytesValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BytesValue.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.value != null && Object.hasOwnProperty.call(message, "value")) + writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.value); + return writer; + }; + + /** + * Encodes the specified BytesValue message, length delimited. Does not implicitly {@link google.protobuf.BytesValue.verify|verify} messages. + * @function encodeDelimited + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.IBytesValue} message BytesValue message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BytesValue.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BytesValue message from the specified reader or buffer. + * @function decode + * @memberof google.protobuf.BytesValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.protobuf.BytesValue} BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BytesValue.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.protobuf.BytesValue(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.value = reader.bytes(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BytesValue message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.protobuf.BytesValue + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.protobuf.BytesValue} BytesValue + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BytesValue.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BytesValue message. + * @function verify + * @memberof google.protobuf.BytesValue + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BytesValue.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.value != null && message.hasOwnProperty("value")) + if (!(message.value && typeof message.value.length === "number" || $util.isString(message.value))) + return "value: buffer expected"; + return null; + }; + + /** + * Creates a BytesValue message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.protobuf.BytesValue + * @static + * @param {Object.} object Plain object + * @returns {google.protobuf.BytesValue} BytesValue + */ + BytesValue.fromObject = function fromObject(object) { + if (object instanceof $root.google.protobuf.BytesValue) + return object; + var message = new $root.google.protobuf.BytesValue(); + if (object.value != null) + if (typeof object.value === "string") + $util.base64.decode(object.value, message.value = $util.newBuffer($util.base64.length(object.value)), 0); + else if (object.value.length >= 0) + message.value = object.value; + return message; + }; + + /** + * Creates a plain object from a BytesValue message. Also converts values to other types if specified. + * @function toObject + * @memberof google.protobuf.BytesValue + * @static + * @param {google.protobuf.BytesValue} message BytesValue + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BytesValue.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + if (options.bytes === String) + object.value = ""; + else { + object.value = []; + if (options.bytes !== Array) + object.value = $util.newBuffer(object.value); + } + if (message.value != null && message.hasOwnProperty("value")) + object.value = options.bytes === String ? $util.base64.encode(message.value, 0, message.value.length) : options.bytes === Array ? Array.prototype.slice.call(message.value) : message.value; + return object; + }; + + /** + * Converts this BytesValue to JSON. + * @function toJSON + * @memberof google.protobuf.BytesValue + * @instance + * @returns {Object.} JSON object + */ + BytesValue.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for BytesValue + * @function getTypeUrl + * @memberof google.protobuf.BytesValue + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + BytesValue.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.protobuf.BytesValue"; + }; + + return BytesValue; + })(); + + return protobuf; + })(); + + google.longrunning = (function() { + + /** + * Namespace longrunning. + * @memberof google + * @namespace + */ + var longrunning = {}; + + longrunning.Operations = (function() { + + /** + * Constructs a new Operations service. + * @memberof google.longrunning + * @classdesc Represents an Operations + * @extends $protobuf.rpc.Service + * @constructor + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + */ + function Operations(rpcImpl, requestDelimited, responseDelimited) { + $protobuf.rpc.Service.call(this, rpcImpl, requestDelimited, responseDelimited); + } + + (Operations.prototype = Object.create($protobuf.rpc.Service.prototype)).constructor = Operations; + + /** + * Creates new Operations service using the specified rpc implementation. + * @function create + * @memberof google.longrunning.Operations + * @static + * @param {$protobuf.RPCImpl} rpcImpl RPC implementation + * @param {boolean} [requestDelimited=false] Whether requests are length-delimited + * @param {boolean} [responseDelimited=false] Whether responses are length-delimited + * @returns {Operations} RPC service. Useful where requests and/or responses are streamed. + */ + Operations.create = function create(rpcImpl, requestDelimited, responseDelimited) { + return new this(rpcImpl, requestDelimited, responseDelimited); + }; + + /** + * Callback as used by {@link google.longrunning.Operations|listOperations}. + * @memberof google.longrunning.Operations + * @typedef ListOperationsCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.ListOperationsResponse} [response] ListOperationsResponse + */ + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @param {google.longrunning.Operations.ListOperationsCallback} callback Node-style callback called with the error, if any, and ListOperationsResponse + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.listOperations = function listOperations(request, callback) { + return this.rpcCall(listOperations, $root.google.longrunning.ListOperationsRequest, $root.google.longrunning.ListOperationsResponse, request, callback); + }, "name", { value: "ListOperations" }); + + /** + * Calls ListOperations. + * @function listOperations + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IListOperationsRequest} request ListOperationsRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations|getOperation}. + * @memberof google.longrunning.Operations + * @typedef GetOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @param {google.longrunning.Operations.GetOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.getOperation = function getOperation(request, callback) { + return this.rpcCall(getOperation, $root.google.longrunning.GetOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "GetOperation" }); + + /** + * Calls GetOperation. + * @function getOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IGetOperationRequest} request GetOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations|deleteOperation}. + * @memberof google.longrunning.Operations + * @typedef DeleteOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @param {google.longrunning.Operations.DeleteOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.deleteOperation = function deleteOperation(request, callback) { + return this.rpcCall(deleteOperation, $root.google.longrunning.DeleteOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "DeleteOperation" }); + + /** + * Calls DeleteOperation. + * @function deleteOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IDeleteOperationRequest} request DeleteOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations|cancelOperation}. + * @memberof google.longrunning.Operations + * @typedef CancelOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.protobuf.Empty} [response] Empty + */ + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @param {google.longrunning.Operations.CancelOperationCallback} callback Node-style callback called with the error, if any, and Empty + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.cancelOperation = function cancelOperation(request, callback) { + return this.rpcCall(cancelOperation, $root.google.longrunning.CancelOperationRequest, $root.google.protobuf.Empty, request, callback); + }, "name", { value: "CancelOperation" }); + + /** + * Calls CancelOperation. + * @function cancelOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.ICancelOperationRequest} request CancelOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + /** + * Callback as used by {@link google.longrunning.Operations|waitOperation}. + * @memberof google.longrunning.Operations + * @typedef WaitOperationCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @param {google.longrunning.Operations.WaitOperationCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(Operations.prototype.waitOperation = function waitOperation(request, callback) { + return this.rpcCall(waitOperation, $root.google.longrunning.WaitOperationRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "WaitOperation" }); + + /** + * Calls WaitOperation. + * @function waitOperation + * @memberof google.longrunning.Operations + * @instance + * @param {google.longrunning.IWaitOperationRequest} request WaitOperationRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + + return Operations; + })(); + + longrunning.Operation = (function() { + + /** + * Properties of an Operation. + * @memberof google.longrunning + * @interface IOperation + * @property {string|null} [name] Operation name + * @property {google.protobuf.IAny|null} [metadata] Operation metadata + * @property {boolean|null} [done] Operation done + * @property {google.rpc.IStatus|null} [error] Operation error + * @property {google.protobuf.IAny|null} [response] Operation response + */ + + /** + * Constructs a new Operation. + * @memberof google.longrunning + * @classdesc Represents an Operation. + * @implements IOperation + * @constructor + * @param {google.longrunning.IOperation=} [properties] Properties to set + */ + function Operation(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Operation name. + * @member {string} name + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.name = ""; + + /** + * Operation metadata. + * @member {google.protobuf.IAny|null|undefined} metadata + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.metadata = null; + + /** + * Operation done. + * @member {boolean} done + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.done = false; + + /** + * Operation error. + * @member {google.rpc.IStatus|null|undefined} error + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.error = null; + + /** + * Operation response. + * @member {google.protobuf.IAny|null|undefined} response + * @memberof google.longrunning.Operation + * @instance + */ + Operation.prototype.response = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * Operation result. + * @member {"error"|"response"|undefined} result + * @memberof google.longrunning.Operation + * @instance + */ + Object.defineProperty(Operation.prototype, "result", { + get: $util.oneOfGetter($oneOfFields = ["error", "response"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new Operation instance using the specified properties. + * @function create + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.IOperation=} [properties] Properties to set + * @returns {google.longrunning.Operation} Operation instance + */ + Operation.create = function create(properties) { + return new Operation(properties); + }; + + /** + * Encodes the specified Operation message. Does not implicitly {@link google.longrunning.Operation.verify|verify} messages. + * @function encode + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.IOperation} message Operation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Operation.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.metadata != null && Object.hasOwnProperty.call(message, "metadata")) + $root.google.protobuf.Any.encode(message.metadata, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.done != null && Object.hasOwnProperty.call(message, "done")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.done); + if (message.error != null && Object.hasOwnProperty.call(message, "error")) + $root.google.rpc.Status.encode(message.error, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.response != null && Object.hasOwnProperty.call(message, "response")) + $root.google.protobuf.Any.encode(message.response, writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Operation message, length delimited. Does not implicitly {@link google.longrunning.Operation.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.IOperation} message Operation message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Operation.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an Operation message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.Operation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.Operation} Operation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Operation.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.Operation(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.metadata = $root.google.protobuf.Any.decode(reader, reader.uint32()); + break; + } + case 3: { + message.done = reader.bool(); + break; + } + case 4: { + message.error = $root.google.rpc.Status.decode(reader, reader.uint32()); + break; + } + case 5: { + message.response = $root.google.protobuf.Any.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an Operation message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.Operation + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.Operation} Operation + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Operation.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an Operation message. + * @function verify + * @memberof google.longrunning.Operation + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Operation.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.metadata != null && message.hasOwnProperty("metadata")) { + var error = $root.google.protobuf.Any.verify(message.metadata); + if (error) + return "metadata." + error; + } + if (message.done != null && message.hasOwnProperty("done")) + if (typeof message.done !== "boolean") + return "done: boolean expected"; + if (message.error != null && message.hasOwnProperty("error")) { + properties.result = 1; + { + var error = $root.google.rpc.Status.verify(message.error); + if (error) + return "error." + error; + } + } + if (message.response != null && message.hasOwnProperty("response")) { + if (properties.result === 1) + return "result: multiple values"; + properties.result = 1; + { + var error = $root.google.protobuf.Any.verify(message.response); + if (error) + return "response." + error; + } + } + return null; + }; + + /** + * Creates an Operation message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.Operation + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.Operation} Operation + */ + Operation.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.Operation) + return object; + var message = new $root.google.longrunning.Operation(); + if (object.name != null) + message.name = String(object.name); + if (object.metadata != null) { + if (typeof object.metadata !== "object") + throw TypeError(".google.longrunning.Operation.metadata: object expected"); + message.metadata = $root.google.protobuf.Any.fromObject(object.metadata); + } + if (object.done != null) + message.done = Boolean(object.done); + if (object.error != null) { + if (typeof object.error !== "object") + throw TypeError(".google.longrunning.Operation.error: object expected"); + message.error = $root.google.rpc.Status.fromObject(object.error); + } + if (object.response != null) { + if (typeof object.response !== "object") + throw TypeError(".google.longrunning.Operation.response: object expected"); + message.response = $root.google.protobuf.Any.fromObject(object.response); + } + return message; + }; + + /** + * Creates a plain object from an Operation message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.Operation + * @static + * @param {google.longrunning.Operation} message Operation + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Operation.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.metadata = null; + object.done = false; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.metadata != null && message.hasOwnProperty("metadata")) + object.metadata = $root.google.protobuf.Any.toObject(message.metadata, options); + if (message.done != null && message.hasOwnProperty("done")) + object.done = message.done; + if (message.error != null && message.hasOwnProperty("error")) { + object.error = $root.google.rpc.Status.toObject(message.error, options); + if (options.oneofs) + object.result = "error"; + } + if (message.response != null && message.hasOwnProperty("response")) { + object.response = $root.google.protobuf.Any.toObject(message.response, options); + if (options.oneofs) + object.result = "response"; + } + return object; + }; + + /** + * Converts this Operation to JSON. + * @function toJSON + * @memberof google.longrunning.Operation + * @instance + * @returns {Object.} JSON object + */ + Operation.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Operation + * @function getTypeUrl + * @memberof google.longrunning.Operation + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Operation.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.Operation"; + }; + + return Operation; + })(); + + longrunning.GetOperationRequest = (function() { + + /** + * Properties of a GetOperationRequest. + * @memberof google.longrunning + * @interface IGetOperationRequest + * @property {string|null} [name] GetOperationRequest name + */ + + /** + * Constructs a new GetOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a GetOperationRequest. + * @implements IGetOperationRequest + * @constructor + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + */ + function GetOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * GetOperationRequest name. + * @member {string} name + * @memberof google.longrunning.GetOperationRequest + * @instance + */ + GetOperationRequest.prototype.name = ""; + + /** + * Creates a new GetOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.IGetOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest instance + */ + GetOperationRequest.create = function create(properties) { + return new GetOperationRequest(properties); + }; + + /** + * Encodes the specified GetOperationRequest message. Does not implicitly {@link google.longrunning.GetOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.IGetOperationRequest} message GetOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetOperationRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified GetOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.GetOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.IGetOperationRequest} message GetOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + GetOperationRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a GetOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.GetOperationRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a GetOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + GetOperationRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a GetOperationRequest message. + * @function verify + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + GetOperationRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a GetOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.GetOperationRequest} GetOperationRequest + */ + GetOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.GetOperationRequest) + return object; + var message = new $root.google.longrunning.GetOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a GetOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {google.longrunning.GetOperationRequest} message GetOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + GetOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this GetOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.GetOperationRequest + * @instance + * @returns {Object.} JSON object + */ + GetOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for GetOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.GetOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + GetOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.GetOperationRequest"; + }; + + return GetOperationRequest; + })(); + + longrunning.ListOperationsRequest = (function() { + + /** + * Properties of a ListOperationsRequest. + * @memberof google.longrunning + * @interface IListOperationsRequest + * @property {string|null} [name] ListOperationsRequest name + * @property {string|null} [filter] ListOperationsRequest filter + * @property {number|null} [pageSize] ListOperationsRequest pageSize + * @property {string|null} [pageToken] ListOperationsRequest pageToken + */ + + /** + * Constructs a new ListOperationsRequest. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsRequest. + * @implements IListOperationsRequest + * @constructor + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + */ + function ListOperationsRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsRequest name. + * @member {string} name + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.name = ""; + + /** + * ListOperationsRequest filter. + * @member {string} filter + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.filter = ""; + + /** + * ListOperationsRequest pageSize. + * @member {number} pageSize + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageSize = 0; + + /** + * ListOperationsRequest pageToken. + * @member {string} pageToken + * @memberof google.longrunning.ListOperationsRequest + * @instance + */ + ListOperationsRequest.prototype.pageToken = ""; + + /** + * Creates a new ListOperationsRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.IListOperationsRequest=} [properties] Properties to set + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest instance + */ + ListOperationsRequest.create = function create(properties) { + return new ListOperationsRequest(properties); + }; + + /** + * Encodes the specified ListOperationsRequest message. Does not implicitly {@link google.longrunning.ListOperationsRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.IListOperationsRequest} message ListOperationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.filter); + if (message.pageSize != null && Object.hasOwnProperty.call(message, "pageSize")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.pageSize); + if (message.pageToken != null && Object.hasOwnProperty.call(message, "pageToken")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.pageToken); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 4, wireType 2 =*/34).string(message.name); + return writer; + }; + + /** + * Encodes the specified ListOperationsRequest message, length delimited. Does not implicitly {@link google.longrunning.ListOperationsRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.IListOperationsRequest} message ListOperationsRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListOperationsRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.ListOperationsRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 4: { + message.name = reader.string(); + break; + } + case 1: { + message.filter = reader.string(); + break; + } + case 2: { + message.pageSize = reader.int32(); + break; + } + case 3: { + message.pageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListOperationsRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListOperationsRequest message. + * @function verify + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListOperationsRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + if (!$util.isInteger(message.pageSize)) + return "pageSize: integer expected"; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + if (!$util.isString(message.pageToken)) + return "pageToken: string expected"; + return null; + }; + + /** + * Creates a ListOperationsRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsRequest} ListOperationsRequest + */ + ListOperationsRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsRequest) + return object; + var message = new $root.google.longrunning.ListOperationsRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.filter != null) + message.filter = String(object.filter); + if (object.pageSize != null) + message.pageSize = object.pageSize | 0; + if (object.pageToken != null) + message.pageToken = String(object.pageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {google.longrunning.ListOperationsRequest} message ListOperationsRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.filter = ""; + object.pageSize = 0; + object.pageToken = ""; + object.name = ""; + } + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; + if (message.pageSize != null && message.hasOwnProperty("pageSize")) + object.pageSize = message.pageSize; + if (message.pageToken != null && message.hasOwnProperty("pageToken")) + object.pageToken = message.pageToken; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this ListOperationsRequest to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsRequest + * @instance + * @returns {Object.} JSON object + */ + ListOperationsRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListOperationsRequest + * @function getTypeUrl + * @memberof google.longrunning.ListOperationsRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListOperationsRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.ListOperationsRequest"; + }; + + return ListOperationsRequest; + })(); + + longrunning.ListOperationsResponse = (function() { + + /** + * Properties of a ListOperationsResponse. + * @memberof google.longrunning + * @interface IListOperationsResponse + * @property {Array.|null} [operations] ListOperationsResponse operations + * @property {string|null} [nextPageToken] ListOperationsResponse nextPageToken + */ + + /** + * Constructs a new ListOperationsResponse. + * @memberof google.longrunning + * @classdesc Represents a ListOperationsResponse. + * @implements IListOperationsResponse + * @constructor + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + */ + function ListOperationsResponse(properties) { + this.operations = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ListOperationsResponse operations. + * @member {Array.} operations + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.operations = $util.emptyArray; + + /** + * ListOperationsResponse nextPageToken. + * @member {string} nextPageToken + * @memberof google.longrunning.ListOperationsResponse + * @instance + */ + ListOperationsResponse.prototype.nextPageToken = ""; + + /** + * Creates a new ListOperationsResponse instance using the specified properties. + * @function create + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.IListOperationsResponse=} [properties] Properties to set + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse instance + */ + ListOperationsResponse.create = function create(properties) { + return new ListOperationsResponse(properties); + }; + + /** + * Encodes the specified ListOperationsResponse message. Does not implicitly {@link google.longrunning.ListOperationsResponse.verify|verify} messages. + * @function encode + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.IListOperationsResponse} message ListOperationsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsResponse.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.operations != null && message.operations.length) + for (var i = 0; i < message.operations.length; ++i) + $root.google.longrunning.Operation.encode(message.operations[i], writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.nextPageToken != null && Object.hasOwnProperty.call(message, "nextPageToken")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.nextPageToken); + return writer; + }; + + /** + * Encodes the specified ListOperationsResponse message, length delimited. Does not implicitly {@link google.longrunning.ListOperationsResponse.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.IListOperationsResponse} message ListOperationsResponse message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ListOperationsResponse.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ListOperationsResponse message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsResponse.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.ListOperationsResponse(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + if (!(message.operations && message.operations.length)) + message.operations = []; + message.operations.push($root.google.longrunning.Operation.decode(reader, reader.uint32())); + break; + } + case 2: { + message.nextPageToken = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ListOperationsResponse message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ListOperationsResponse.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ListOperationsResponse message. + * @function verify + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ListOperationsResponse.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.operations != null && message.hasOwnProperty("operations")) { + if (!Array.isArray(message.operations)) + return "operations: array expected"; + for (var i = 0; i < message.operations.length; ++i) { + var error = $root.google.longrunning.Operation.verify(message.operations[i]); + if (error) + return "operations." + error; + } + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + if (!$util.isString(message.nextPageToken)) + return "nextPageToken: string expected"; + return null; + }; + + /** + * Creates a ListOperationsResponse message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.ListOperationsResponse} ListOperationsResponse + */ + ListOperationsResponse.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.ListOperationsResponse) + return object; + var message = new $root.google.longrunning.ListOperationsResponse(); + if (object.operations) { + if (!Array.isArray(object.operations)) + throw TypeError(".google.longrunning.ListOperationsResponse.operations: array expected"); + message.operations = []; + for (var i = 0; i < object.operations.length; ++i) { + if (typeof object.operations[i] !== "object") + throw TypeError(".google.longrunning.ListOperationsResponse.operations: object expected"); + message.operations[i] = $root.google.longrunning.Operation.fromObject(object.operations[i]); + } + } + if (object.nextPageToken != null) + message.nextPageToken = String(object.nextPageToken); + return message; + }; + + /** + * Creates a plain object from a ListOperationsResponse message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {google.longrunning.ListOperationsResponse} message ListOperationsResponse + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ListOperationsResponse.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.operations = []; + if (options.defaults) + object.nextPageToken = ""; + if (message.operations && message.operations.length) { + object.operations = []; + for (var j = 0; j < message.operations.length; ++j) + object.operations[j] = $root.google.longrunning.Operation.toObject(message.operations[j], options); + } + if (message.nextPageToken != null && message.hasOwnProperty("nextPageToken")) + object.nextPageToken = message.nextPageToken; + return object; + }; + + /** + * Converts this ListOperationsResponse to JSON. + * @function toJSON + * @memberof google.longrunning.ListOperationsResponse + * @instance + * @returns {Object.} JSON object + */ + ListOperationsResponse.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ListOperationsResponse + * @function getTypeUrl + * @memberof google.longrunning.ListOperationsResponse + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ListOperationsResponse.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.ListOperationsResponse"; + }; + + return ListOperationsResponse; + })(); + + longrunning.CancelOperationRequest = (function() { + + /** + * Properties of a CancelOperationRequest. + * @memberof google.longrunning + * @interface ICancelOperationRequest + * @property {string|null} [name] CancelOperationRequest name + */ + + /** + * Constructs a new CancelOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a CancelOperationRequest. + * @implements ICancelOperationRequest + * @constructor + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + */ + function CancelOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CancelOperationRequest name. + * @member {string} name + * @memberof google.longrunning.CancelOperationRequest + * @instance + */ + CancelOperationRequest.prototype.name = ""; + + /** + * Creates a new CancelOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.ICancelOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest instance + */ + CancelOperationRequest.create = function create(properties) { + return new CancelOperationRequest(properties); + }; + + /** + * Encodes the specified CancelOperationRequest message. Does not implicitly {@link google.longrunning.CancelOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.ICancelOperationRequest} message CancelOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CancelOperationRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified CancelOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.CancelOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.ICancelOperationRequest} message CancelOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CancelOperationRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CancelOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CancelOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.CancelOperationRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CancelOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CancelOperationRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CancelOperationRequest message. + * @function verify + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CancelOperationRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a CancelOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.CancelOperationRequest} CancelOperationRequest + */ + CancelOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.CancelOperationRequest) + return object; + var message = new $root.google.longrunning.CancelOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a CancelOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {google.longrunning.CancelOperationRequest} message CancelOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CancelOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this CancelOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.CancelOperationRequest + * @instance + * @returns {Object.} JSON object + */ + CancelOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CancelOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.CancelOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CancelOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.CancelOperationRequest"; + }; + + return CancelOperationRequest; + })(); + + longrunning.DeleteOperationRequest = (function() { + + /** + * Properties of a DeleteOperationRequest. + * @memberof google.longrunning + * @interface IDeleteOperationRequest + * @property {string|null} [name] DeleteOperationRequest name + */ + + /** + * Constructs a new DeleteOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a DeleteOperationRequest. + * @implements IDeleteOperationRequest + * @constructor + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + */ + function DeleteOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeleteOperationRequest name. + * @member {string} name + * @memberof google.longrunning.DeleteOperationRequest + * @instance + */ + DeleteOperationRequest.prototype.name = ""; + + /** + * Creates a new DeleteOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.IDeleteOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest instance + */ + DeleteOperationRequest.create = function create(properties) { + return new DeleteOperationRequest(properties); + }; + + /** + * Encodes the specified DeleteOperationRequest message. Does not implicitly {@link google.longrunning.DeleteOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.IDeleteOperationRequest} message DeleteOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteOperationRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + return writer; + }; + + /** + * Encodes the specified DeleteOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.DeleteOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.IDeleteOperationRequest} message DeleteOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + DeleteOperationRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a DeleteOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.DeleteOperationRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a DeleteOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + DeleteOperationRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a DeleteOperationRequest message. + * @function verify + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + DeleteOperationRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + return null; + }; + + /** + * Creates a DeleteOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.DeleteOperationRequest} DeleteOperationRequest + */ + DeleteOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.DeleteOperationRequest) + return object; + var message = new $root.google.longrunning.DeleteOperationRequest(); + if (object.name != null) + message.name = String(object.name); + return message; + }; + + /** + * Creates a plain object from a DeleteOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {google.longrunning.DeleteOperationRequest} message DeleteOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + DeleteOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.name = ""; + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + return object; + }; + + /** + * Converts this DeleteOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.DeleteOperationRequest + * @instance + * @returns {Object.} JSON object + */ + DeleteOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for DeleteOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.DeleteOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + DeleteOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.DeleteOperationRequest"; + }; + + return DeleteOperationRequest; + })(); + + longrunning.WaitOperationRequest = (function() { + + /** + * Properties of a WaitOperationRequest. + * @memberof google.longrunning + * @interface IWaitOperationRequest + * @property {string|null} [name] WaitOperationRequest name + * @property {google.protobuf.IDuration|null} [timeout] WaitOperationRequest timeout + */ + + /** + * Constructs a new WaitOperationRequest. + * @memberof google.longrunning + * @classdesc Represents a WaitOperationRequest. + * @implements IWaitOperationRequest + * @constructor + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + */ + function WaitOperationRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WaitOperationRequest name. + * @member {string} name + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.name = ""; + + /** + * WaitOperationRequest timeout. + * @member {google.protobuf.IDuration|null|undefined} timeout + * @memberof google.longrunning.WaitOperationRequest + * @instance + */ + WaitOperationRequest.prototype.timeout = null; + + /** + * Creates a new WaitOperationRequest instance using the specified properties. + * @function create + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.IWaitOperationRequest=} [properties] Properties to set + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest instance + */ + WaitOperationRequest.create = function create(properties) { + return new WaitOperationRequest(properties); + }; + + /** + * Encodes the specified WaitOperationRequest message. Does not implicitly {@link google.longrunning.WaitOperationRequest.verify|verify} messages. + * @function encode + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.IWaitOperationRequest} message WaitOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WaitOperationRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.timeout != null && Object.hasOwnProperty.call(message, "timeout")) + $root.google.protobuf.Duration.encode(message.timeout, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified WaitOperationRequest message, length delimited. Does not implicitly {@link google.longrunning.WaitOperationRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.IWaitOperationRequest} message WaitOperationRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WaitOperationRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WaitOperationRequest message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WaitOperationRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.WaitOperationRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.name = reader.string(); + break; + } + case 2: { + message.timeout = $root.google.protobuf.Duration.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WaitOperationRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WaitOperationRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WaitOperationRequest message. + * @function verify + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WaitOperationRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.timeout != null && message.hasOwnProperty("timeout")) { + var error = $root.google.protobuf.Duration.verify(message.timeout); + if (error) + return "timeout." + error; + } + return null; + }; + + /** + * Creates a WaitOperationRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.WaitOperationRequest} WaitOperationRequest + */ + WaitOperationRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.WaitOperationRequest) + return object; + var message = new $root.google.longrunning.WaitOperationRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.timeout != null) { + if (typeof object.timeout !== "object") + throw TypeError(".google.longrunning.WaitOperationRequest.timeout: object expected"); + message.timeout = $root.google.protobuf.Duration.fromObject(object.timeout); + } + return message; + }; + + /** + * Creates a plain object from a WaitOperationRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {google.longrunning.WaitOperationRequest} message WaitOperationRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WaitOperationRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.timeout = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.timeout != null && message.hasOwnProperty("timeout")) + object.timeout = $root.google.protobuf.Duration.toObject(message.timeout, options); + return object; + }; + + /** + * Converts this WaitOperationRequest to JSON. + * @function toJSON + * @memberof google.longrunning.WaitOperationRequest + * @instance + * @returns {Object.} JSON object + */ + WaitOperationRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WaitOperationRequest + * @function getTypeUrl + * @memberof google.longrunning.WaitOperationRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WaitOperationRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.WaitOperationRequest"; + }; + + return WaitOperationRequest; + })(); + + longrunning.OperationInfo = (function() { + + /** + * Properties of an OperationInfo. + * @memberof google.longrunning + * @interface IOperationInfo + * @property {string|null} [responseType] OperationInfo responseType + * @property {string|null} [metadataType] OperationInfo metadataType + */ + + /** + * Constructs a new OperationInfo. + * @memberof google.longrunning + * @classdesc Represents an OperationInfo. + * @implements IOperationInfo + * @constructor + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + */ + function OperationInfo(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * OperationInfo responseType. + * @member {string} responseType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.responseType = ""; + + /** + * OperationInfo metadataType. + * @member {string} metadataType + * @memberof google.longrunning.OperationInfo + * @instance + */ + OperationInfo.prototype.metadataType = ""; + + /** + * Creates a new OperationInfo instance using the specified properties. + * @function create + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.IOperationInfo=} [properties] Properties to set + * @returns {google.longrunning.OperationInfo} OperationInfo instance + */ + OperationInfo.create = function create(properties) { + return new OperationInfo(properties); + }; + + /** + * Encodes the specified OperationInfo message. Does not implicitly {@link google.longrunning.OperationInfo.verify|verify} messages. + * @function encode + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.IOperationInfo} message OperationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationInfo.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.responseType != null && Object.hasOwnProperty.call(message, "responseType")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.responseType); + if (message.metadataType != null && Object.hasOwnProperty.call(message, "metadataType")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.metadataType); + return writer; + }; + + /** + * Encodes the specified OperationInfo message, length delimited. Does not implicitly {@link google.longrunning.OperationInfo.verify|verify} messages. + * @function encodeDelimited + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.IOperationInfo} message OperationInfo message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + OperationInfo.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an OperationInfo message from the specified reader or buffer. + * @function decode + * @memberof google.longrunning.OperationInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.longrunning.OperationInfo} OperationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationInfo.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.longrunning.OperationInfo(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.responseType = reader.string(); + break; + } + case 2: { + message.metadataType = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an OperationInfo message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.longrunning.OperationInfo + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.longrunning.OperationInfo} OperationInfo + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + OperationInfo.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an OperationInfo message. + * @function verify + * @memberof google.longrunning.OperationInfo + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + OperationInfo.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.responseType != null && message.hasOwnProperty("responseType")) + if (!$util.isString(message.responseType)) + return "responseType: string expected"; + if (message.metadataType != null && message.hasOwnProperty("metadataType")) + if (!$util.isString(message.metadataType)) + return "metadataType: string expected"; + return null; + }; + + /** + * Creates an OperationInfo message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {Object.} object Plain object + * @returns {google.longrunning.OperationInfo} OperationInfo + */ + OperationInfo.fromObject = function fromObject(object) { + if (object instanceof $root.google.longrunning.OperationInfo) + return object; + var message = new $root.google.longrunning.OperationInfo(); + if (object.responseType != null) + message.responseType = String(object.responseType); + if (object.metadataType != null) + message.metadataType = String(object.metadataType); + return message; + }; + + /** + * Creates a plain object from an OperationInfo message. Also converts values to other types if specified. + * @function toObject + * @memberof google.longrunning.OperationInfo + * @static + * @param {google.longrunning.OperationInfo} message OperationInfo + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + OperationInfo.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.responseType = ""; + object.metadataType = ""; + } + if (message.responseType != null && message.hasOwnProperty("responseType")) + object.responseType = message.responseType; + if (message.metadataType != null && message.hasOwnProperty("metadataType")) + object.metadataType = message.metadataType; + return object; + }; + + /** + * Converts this OperationInfo to JSON. + * @function toJSON + * @memberof google.longrunning.OperationInfo + * @instance + * @returns {Object.} JSON object + */ + OperationInfo.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for OperationInfo + * @function getTypeUrl + * @memberof google.longrunning.OperationInfo + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + OperationInfo.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.longrunning.OperationInfo"; + }; + + return OperationInfo; + })(); + + return longrunning; + })(); + + google.rpc = (function() { + + /** + * Namespace rpc. + * @memberof google + * @namespace + */ + var rpc = {}; + + rpc.Status = (function() { + + /** + * Properties of a Status. + * @memberof google.rpc + * @interface IStatus + * @property {number|null} [code] Status code + * @property {string|null} [message] Status message + * @property {Array.|null} [details] Status details + */ + + /** + * Constructs a new Status. + * @memberof google.rpc + * @classdesc Represents a Status. + * @implements IStatus + * @constructor + * @param {google.rpc.IStatus=} [properties] Properties to set + */ + function Status(properties) { + this.details = []; + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * Status code. + * @member {number} code + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.code = 0; + + /** + * Status message. + * @member {string} message + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.message = ""; + + /** + * Status details. + * @member {Array.} details + * @memberof google.rpc.Status + * @instance + */ + Status.prototype.details = $util.emptyArray; + + /** + * Creates a new Status instance using the specified properties. + * @function create + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus=} [properties] Properties to set + * @returns {google.rpc.Status} Status instance + */ + Status.create = function create(properties) { + return new Status(properties); + }; + + /** + * Encodes the specified Status message. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encode + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.code != null && Object.hasOwnProperty.call(message, "code")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.code); + if (message.message != null && Object.hasOwnProperty.call(message, "message")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.message); + if (message.details != null && message.details.length) + for (var i = 0; i < message.details.length; ++i) + $root.google.protobuf.Any.encode(message.details[i], writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified Status message, length delimited. Does not implicitly {@link google.rpc.Status.verify|verify} messages. + * @function encodeDelimited + * @memberof google.rpc.Status + * @static + * @param {google.rpc.IStatus} message Status message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + Status.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a Status message from the specified reader or buffer. + * @function decode + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.rpc.Status(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.code = reader.int32(); + break; + } + case 2: { + message.message = reader.string(); + break; + } + case 3: { + if (!(message.details && message.details.length)) + message.details = []; + message.details.push($root.google.protobuf.Any.decode(reader, reader.uint32())); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a Status message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.rpc.Status + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.rpc.Status} Status + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + Status.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a Status message. + * @function verify + * @memberof google.rpc.Status + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + Status.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.code != null && message.hasOwnProperty("code")) + if (!$util.isInteger(message.code)) + return "code: integer expected"; + if (message.message != null && message.hasOwnProperty("message")) + if (!$util.isString(message.message)) + return "message: string expected"; + if (message.details != null && message.hasOwnProperty("details")) { + if (!Array.isArray(message.details)) + return "details: array expected"; + for (var i = 0; i < message.details.length; ++i) { + var error = $root.google.protobuf.Any.verify(message.details[i]); + if (error) + return "details." + error; + } + } + return null; + }; + + /** + * Creates a Status message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.rpc.Status + * @static + * @param {Object.} object Plain object + * @returns {google.rpc.Status} Status + */ + Status.fromObject = function fromObject(object) { + if (object instanceof $root.google.rpc.Status) + return object; + var message = new $root.google.rpc.Status(); + if (object.code != null) + message.code = object.code | 0; + if (object.message != null) + message.message = String(object.message); + if (object.details) { + if (!Array.isArray(object.details)) + throw TypeError(".google.rpc.Status.details: array expected"); + message.details = []; + for (var i = 0; i < object.details.length; ++i) { + if (typeof object.details[i] !== "object") + throw TypeError(".google.rpc.Status.details: object expected"); + message.details[i] = $root.google.protobuf.Any.fromObject(object.details[i]); + } + } + return message; + }; + + /** + * Creates a plain object from a Status message. Also converts values to other types if specified. + * @function toObject + * @memberof google.rpc.Status + * @static + * @param {google.rpc.Status} message Status + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + Status.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.arrays || options.defaults) + object.details = []; + if (options.defaults) { + object.code = 0; + object.message = ""; + } + if (message.code != null && message.hasOwnProperty("code")) + object.code = message.code; + if (message.message != null && message.hasOwnProperty("message")) + object.message = message.message; + if (message.details && message.details.length) { + object.details = []; + for (var j = 0; j < message.details.length; ++j) + object.details[j] = $root.google.protobuf.Any.toObject(message.details[j], options); + } + return object; + }; + + /** + * Converts this Status to JSON. + * @function toJSON + * @memberof google.rpc.Status + * @instance + * @returns {Object.} JSON object + */ + Status.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for Status + * @function getTypeUrl + * @memberof google.rpc.Status + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + Status.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.rpc.Status"; + }; + + return Status; + })(); + + return rpc; + })(); + + google.type = (function() { + + /** + * Namespace type. + * @memberof google + * @namespace + */ + var type = {}; + + type.LatLng = (function() { + + /** + * Properties of a LatLng. + * @memberof google.type + * @interface ILatLng + * @property {number|null} [latitude] LatLng latitude + * @property {number|null} [longitude] LatLng longitude + */ + + /** + * Constructs a new LatLng. + * @memberof google.type + * @classdesc Represents a LatLng. + * @implements ILatLng + * @constructor + * @param {google.type.ILatLng=} [properties] Properties to set + */ + function LatLng(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * LatLng latitude. + * @member {number} latitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.latitude = 0; + + /** + * LatLng longitude. + * @member {number} longitude + * @memberof google.type.LatLng + * @instance + */ + LatLng.prototype.longitude = 0; + + /** + * Creates a new LatLng instance using the specified properties. + * @function create + * @memberof google.type.LatLng + * @static + * @param {google.type.ILatLng=} [properties] Properties to set + * @returns {google.type.LatLng} LatLng instance + */ + LatLng.create = function create(properties) { + return new LatLng(properties); + }; + + /** + * Encodes the specified LatLng message. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @function encode + * @memberof google.type.LatLng + * @static + * @param {google.type.ILatLng} message LatLng message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LatLng.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.latitude != null && Object.hasOwnProperty.call(message, "latitude")) + writer.uint32(/* id 1, wireType 1 =*/9).double(message.latitude); + if (message.longitude != null && Object.hasOwnProperty.call(message, "longitude")) + writer.uint32(/* id 2, wireType 1 =*/17).double(message.longitude); + return writer; + }; + + /** + * Encodes the specified LatLng message, length delimited. Does not implicitly {@link google.type.LatLng.verify|verify} messages. + * @function encodeDelimited + * @memberof google.type.LatLng + * @static + * @param {google.type.ILatLng} message LatLng message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + LatLng.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a LatLng message from the specified reader or buffer. + * @function decode + * @memberof google.type.LatLng + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.type.LatLng} LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LatLng.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.type.LatLng(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.latitude = reader.double(); + break; + } + case 2: { + message.longitude = reader.double(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a LatLng message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.type.LatLng + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.type.LatLng} LatLng + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + LatLng.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a LatLng message. + * @function verify + * @memberof google.type.LatLng + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + LatLng.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.latitude != null && message.hasOwnProperty("latitude")) + if (typeof message.latitude !== "number") + return "latitude: number expected"; + if (message.longitude != null && message.hasOwnProperty("longitude")) + if (typeof message.longitude !== "number") + return "longitude: number expected"; + return null; + }; + + /** + * Creates a LatLng message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.type.LatLng + * @static + * @param {Object.} object Plain object + * @returns {google.type.LatLng} LatLng + */ + LatLng.fromObject = function fromObject(object) { + if (object instanceof $root.google.type.LatLng) + return object; + var message = new $root.google.type.LatLng(); + if (object.latitude != null) + message.latitude = Number(object.latitude); + if (object.longitude != null) + message.longitude = Number(object.longitude); + return message; + }; + + /** + * Creates a plain object from a LatLng message. Also converts values to other types if specified. + * @function toObject + * @memberof google.type.LatLng + * @static + * @param {google.type.LatLng} message LatLng + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + LatLng.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.latitude = 0; + object.longitude = 0; + } + if (message.latitude != null && message.hasOwnProperty("latitude")) + object.latitude = options.json && !isFinite(message.latitude) ? String(message.latitude) : message.latitude; + if (message.longitude != null && message.hasOwnProperty("longitude")) + object.longitude = options.json && !isFinite(message.longitude) ? String(message.longitude) : message.longitude; + return object; + }; + + /** + * Converts this LatLng to JSON. + * @function toJSON + * @memberof google.type.LatLng + * @instance + * @returns {Object.} JSON object + */ + LatLng.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for LatLng + * @function getTypeUrl + * @memberof google.type.LatLng + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + LatLng.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.type.LatLng"; + }; + + return LatLng; + })(); + + return type; + })(); + + return google; + })(); + + return $root; +}); diff --git a/handwritten/nodejs-datastore/protos/protos.json b/handwritten/nodejs-datastore/protos/protos.json new file mode 100644 index 00000000000..b35941f37fd --- /dev/null +++ b/handwritten/nodejs-datastore/protos/protos.json @@ -0,0 +1,4526 @@ +{ + "options": { + "syntax": "proto3" + }, + "nested": { + "google": { + "nested": { + "datastore": { + "nested": { + "admin": { + "nested": { + "v1": { + "options": { + "csharp_namespace": "Google.Cloud.Datastore.Admin.V1", + "go_package": "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb", + "java_multiple_files": true, + "java_outer_classname": "MigrationProto", + "java_package": "com.google.datastore.admin.v1", + "php_namespace": "Google\\Cloud\\Datastore\\Admin\\V1", + "ruby_package": "Google::Cloud::Datastore::Admin::V1" + }, + "nested": { + "DatastoreAdmin": { + "options": { + "(google.api.default_host)": "datastore.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" + }, + "methods": { + "ExportEntities": { + "requestType": "ExportEntitiesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:export", + "(google.api.http).body": "*", + "(google.api.method_signature)": "project_id,labels,entity_filter,output_url_prefix", + "(google.longrunning.operation_info).response_type": "ExportEntitiesResponse", + "(google.longrunning.operation_info).metadata_type": "ExportEntitiesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:export", + "body": "*" + } + }, + { + "(google.api.method_signature)": "project_id,labels,entity_filter,output_url_prefix" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "ExportEntitiesResponse", + "metadata_type": "ExportEntitiesMetadata" + } + } + ] + }, + "ImportEntities": { + "requestType": "ImportEntitiesRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:import", + "(google.api.http).body": "*", + "(google.api.method_signature)": "project_id,labels,input_url,entity_filter", + "(google.longrunning.operation_info).response_type": "google.protobuf.Empty", + "(google.longrunning.operation_info).metadata_type": "ImportEntitiesMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:import", + "body": "*" + } + }, + { + "(google.api.method_signature)": "project_id,labels,input_url,entity_filter" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "google.protobuf.Empty", + "metadata_type": "ImportEntitiesMetadata" + } + } + ] + }, + "CreateIndex": { + "requestType": "CreateIndexRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}/indexes", + "(google.api.http).body": "index", + "(google.longrunning.operation_info).response_type": "Index", + "(google.longrunning.operation_info).metadata_type": "IndexOperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}/indexes", + "body": "index" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Index", + "metadata_type": "IndexOperationMetadata" + } + } + ] + }, + "DeleteIndex": { + "requestType": "DeleteIndexRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).delete": "/v1/projects/{project_id}/indexes/{index_id}", + "(google.longrunning.operation_info).response_type": "Index", + "(google.longrunning.operation_info).metadata_type": "IndexOperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/projects/{project_id}/indexes/{index_id}" + } + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Index", + "metadata_type": "IndexOperationMetadata" + } + } + ] + }, + "GetIndex": { + "requestType": "GetIndexRequest", + "responseType": "Index", + "options": { + "(google.api.http).get": "/v1/projects/{project_id}/indexes/{index_id}" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/projects/{project_id}/indexes/{index_id}" + } + } + ] + }, + "ListIndexes": { + "requestType": "ListIndexesRequest", + "responseType": "ListIndexesResponse", + "options": { + "(google.api.http).get": "/v1/projects/{project_id}/indexes" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/projects/{project_id}/indexes" + } + } + ] + } + } + }, + "CommonMetadata": { + "fields": { + "startTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + }, + "endTime": { + "type": "google.protobuf.Timestamp", + "id": 2 + }, + "operationType": { + "type": "OperationType", + "id": 3 + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 4 + }, + "state": { + "type": "State", + "id": 5 + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "INITIALIZING": 1, + "PROCESSING": 2, + "CANCELLING": 3, + "FINALIZING": 4, + "SUCCESSFUL": 5, + "FAILED": 6, + "CANCELLED": 7 + } + } + } + }, + "Progress": { + "fields": { + "workCompleted": { + "type": "int64", + "id": 1 + }, + "workEstimated": { + "type": "int64", + "id": 2 + } + } + }, + "ExportEntitiesRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 2 + }, + "entityFilter": { + "type": "EntityFilter", + "id": 3 + }, + "outputUrlPrefix": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ImportEntitiesRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "labels": { + "keyType": "string", + "type": "string", + "id": 2 + }, + "inputUrl": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "entityFilter": { + "type": "EntityFilter", + "id": 4 + } + } + }, + "ExportEntitiesResponse": { + "fields": { + "outputUrl": { + "type": "string", + "id": 1 + } + } + }, + "ExportEntitiesMetadata": { + "fields": { + "common": { + "type": "CommonMetadata", + "id": 1 + }, + "progressEntities": { + "type": "Progress", + "id": 2 + }, + "progressBytes": { + "type": "Progress", + "id": 3 + }, + "entityFilter": { + "type": "EntityFilter", + "id": 4 + }, + "outputUrlPrefix": { + "type": "string", + "id": 5 + } + } + }, + "ImportEntitiesMetadata": { + "fields": { + "common": { + "type": "CommonMetadata", + "id": 1 + }, + "progressEntities": { + "type": "Progress", + "id": 2 + }, + "progressBytes": { + "type": "Progress", + "id": 3 + }, + "entityFilter": { + "type": "EntityFilter", + "id": 4 + }, + "inputUrl": { + "type": "string", + "id": 5 + } + } + }, + "EntityFilter": { + "fields": { + "kinds": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "namespaceIds": { + "rule": "repeated", + "type": "string", + "id": 2 + } + } + }, + "CreateIndexRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 1 + }, + "index": { + "type": "Index", + "id": 3 + } + } + }, + "DeleteIndexRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 1 + }, + "indexId": { + "type": "string", + "id": 3 + } + } + }, + "GetIndexRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 1 + }, + "indexId": { + "type": "string", + "id": 3 + } + } + }, + "ListIndexesRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 1 + }, + "filter": { + "type": "string", + "id": 3 + }, + "pageSize": { + "type": "int32", + "id": 4 + }, + "pageToken": { + "type": "string", + "id": 5 + } + } + }, + "ListIndexesResponse": { + "fields": { + "indexes": { + "rule": "repeated", + "type": "Index", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "IndexOperationMetadata": { + "fields": { + "common": { + "type": "CommonMetadata", + "id": 1 + }, + "progressEntities": { + "type": "Progress", + "id": 2 + }, + "indexId": { + "type": "string", + "id": 3 + } + } + }, + "DatastoreFirestoreMigrationMetadata": { + "fields": { + "migrationState": { + "type": "MigrationState", + "id": 1 + }, + "migrationStep": { + "type": "MigrationStep", + "id": 2 + } + } + }, + "OperationType": { + "values": { + "OPERATION_TYPE_UNSPECIFIED": 0, + "EXPORT_ENTITIES": 1, + "IMPORT_ENTITIES": 2, + "CREATE_INDEX": 3, + "DELETE_INDEX": 4 + } + }, + "Index": { + "fields": { + "projectId": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "indexId": { + "type": "string", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "kind": { + "type": "string", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "ancestor": { + "type": "AncestorMode", + "id": 5, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "properties": { + "rule": "repeated", + "type": "IndexedProperty", + "id": 6, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "state": { + "type": "State", + "id": 7, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "AncestorMode": { + "values": { + "ANCESTOR_MODE_UNSPECIFIED": 0, + "NONE": 1, + "ALL_ANCESTORS": 2 + } + }, + "Direction": { + "values": { + "DIRECTION_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 + } + }, + "IndexedProperty": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "direction": { + "type": "Direction", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "CREATING": 1, + "READY": 2, + "DELETING": 3, + "ERROR": 4 + } + } + } + }, + "MigrationStateEvent": { + "fields": { + "state": { + "type": "MigrationState", + "id": 1 + } + } + }, + "MigrationProgressEvent": { + "oneofs": { + "stepDetails": { + "oneof": [ + "prepareStepDetails", + "redirectWritesStepDetails" + ] + } + }, + "fields": { + "step": { + "type": "MigrationStep", + "id": 1 + }, + "prepareStepDetails": { + "type": "PrepareStepDetails", + "id": 2 + }, + "redirectWritesStepDetails": { + "type": "RedirectWritesStepDetails", + "id": 3 + } + }, + "nested": { + "ConcurrencyMode": { + "values": { + "CONCURRENCY_MODE_UNSPECIFIED": 0, + "PESSIMISTIC": 1, + "OPTIMISTIC": 2, + "OPTIMISTIC_WITH_ENTITY_GROUPS": 3 + } + }, + "PrepareStepDetails": { + "fields": { + "concurrencyMode": { + "type": "ConcurrencyMode", + "id": 1 + } + } + }, + "RedirectWritesStepDetails": { + "fields": { + "concurrencyMode": { + "type": "ConcurrencyMode", + "id": 1 + } + } + } + } + }, + "MigrationState": { + "values": { + "MIGRATION_STATE_UNSPECIFIED": 0, + "RUNNING": 1, + "PAUSED": 2, + "COMPLETE": 3 + } + }, + "MigrationStep": { + "values": { + "MIGRATION_STEP_UNSPECIFIED": 0, + "PREPARE": 6, + "START": 1, + "APPLY_WRITES_SYNCHRONOUSLY": 7, + "COPY_AND_VERIFY": 2, + "REDIRECT_EVENTUALLY_CONSISTENT_READS": 3, + "REDIRECT_STRONGLY_CONSISTENT_READS": 4, + "REDIRECT_WRITES": 5 + } + } + } + } + } + }, + "v1": { + "options": { + "csharp_namespace": "Google.Cloud.Datastore.V1", + "go_package": "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb", + "java_multiple_files": true, + "java_outer_classname": "QueryProfileProto", + "java_package": "com.google.datastore.v1", + "php_namespace": "Google\\Cloud\\Datastore\\V1", + "ruby_package": "Google::Cloud::Datastore::V1" + }, + "nested": { + "AggregationResult": { + "fields": { + "aggregateProperties": { + "keyType": "string", + "type": "Value", + "id": 2 + } + } + }, + "AggregationResultBatch": { + "fields": { + "aggregationResults": { + "rule": "repeated", + "type": "AggregationResult", + "id": 1 + }, + "moreResults": { + "type": "QueryResultBatch.MoreResultsType", + "id": 2 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 3 + } + } + }, + "PartitionId": { + "fields": { + "projectId": { + "type": "string", + "id": 2 + }, + "databaseId": { + "type": "string", + "id": 3 + }, + "namespaceId": { + "type": "string", + "id": 4 + } + } + }, + "Key": { + "fields": { + "partitionId": { + "type": "PartitionId", + "id": 1 + }, + "path": { + "rule": "repeated", + "type": "PathElement", + "id": 2 + } + }, + "nested": { + "PathElement": { + "oneofs": { + "idType": { + "oneof": [ + "id", + "name" + ] + } + }, + "fields": { + "kind": { + "type": "string", + "id": 1 + }, + "id": { + "type": "int64", + "id": 2 + }, + "name": { + "type": "string", + "id": 3 + } + } + } + } + }, + "ArrayValue": { + "fields": { + "values": { + "rule": "repeated", + "type": "Value", + "id": 1 + } + } + }, + "Value": { + "oneofs": { + "valueType": { + "oneof": [ + "nullValue", + "booleanValue", + "integerValue", + "doubleValue", + "timestampValue", + "keyValue", + "stringValue", + "blobValue", + "geoPointValue", + "entityValue", + "arrayValue" + ] + } + }, + "fields": { + "nullValue": { + "type": "google.protobuf.NullValue", + "id": 11 + }, + "booleanValue": { + "type": "bool", + "id": 1 + }, + "integerValue": { + "type": "int64", + "id": 2 + }, + "doubleValue": { + "type": "double", + "id": 3 + }, + "timestampValue": { + "type": "google.protobuf.Timestamp", + "id": 10 + }, + "keyValue": { + "type": "Key", + "id": 5 + }, + "stringValue": { + "type": "string", + "id": 17 + }, + "blobValue": { + "type": "bytes", + "id": 18 + }, + "geoPointValue": { + "type": "google.type.LatLng", + "id": 8 + }, + "entityValue": { + "type": "Entity", + "id": 6 + }, + "arrayValue": { + "type": "ArrayValue", + "id": 9 + }, + "meaning": { + "type": "int32", + "id": 14 + }, + "excludeFromIndexes": { + "type": "bool", + "id": 19 + } + } + }, + "Entity": { + "fields": { + "key": { + "type": "Key", + "id": 1 + }, + "properties": { + "keyType": "string", + "type": "Value", + "id": 3 + } + } + }, + "EntityResult": { + "fields": { + "entity": { + "type": "Entity", + "id": 1 + }, + "version": { + "type": "int64", + "id": 4 + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 6 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 5 + }, + "cursor": { + "type": "bytes", + "id": 3 + } + }, + "nested": { + "ResultType": { + "values": { + "RESULT_TYPE_UNSPECIFIED": 0, + "FULL": 1, + "PROJECTION": 2, + "KEY_ONLY": 3 + } + } + } + }, + "Query": { + "fields": { + "projection": { + "rule": "repeated", + "type": "Projection", + "id": 2 + }, + "kind": { + "rule": "repeated", + "type": "KindExpression", + "id": 3 + }, + "filter": { + "type": "Filter", + "id": 4 + }, + "order": { + "rule": "repeated", + "type": "PropertyOrder", + "id": 5 + }, + "distinctOn": { + "rule": "repeated", + "type": "PropertyReference", + "id": 6 + }, + "startCursor": { + "type": "bytes", + "id": 7 + }, + "endCursor": { + "type": "bytes", + "id": 8 + }, + "offset": { + "type": "int32", + "id": 10 + }, + "limit": { + "type": "google.protobuf.Int32Value", + "id": 12 + }, + "findNearest": { + "type": "FindNearest", + "id": 13, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "AggregationQuery": { + "oneofs": { + "queryType": { + "oneof": [ + "nestedQuery" + ] + } + }, + "fields": { + "nestedQuery": { + "type": "Query", + "id": 1 + }, + "aggregations": { + "rule": "repeated", + "type": "Aggregation", + "id": 3, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "Aggregation": { + "oneofs": { + "operator": { + "oneof": [ + "count", + "sum", + "avg" + ] + } + }, + "fields": { + "count": { + "type": "Count", + "id": 1 + }, + "sum": { + "type": "Sum", + "id": 2 + }, + "avg": { + "type": "Avg", + "id": 3 + }, + "alias": { + "type": "string", + "id": 7, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "Count": { + "fields": { + "upTo": { + "type": "google.protobuf.Int64Value", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "Sum": { + "fields": { + "property": { + "type": "PropertyReference", + "id": 1 + } + } + }, + "Avg": { + "fields": { + "property": { + "type": "PropertyReference", + "id": 1 + } + } + } + } + } + } + }, + "KindExpression": { + "fields": { + "name": { + "type": "string", + "id": 1 + } + } + }, + "PropertyReference": { + "fields": { + "name": { + "type": "string", + "id": 2 + } + } + }, + "Projection": { + "fields": { + "property": { + "type": "PropertyReference", + "id": 1 + } + } + }, + "PropertyOrder": { + "fields": { + "property": { + "type": "PropertyReference", + "id": 1 + }, + "direction": { + "type": "Direction", + "id": 2 + } + }, + "nested": { + "Direction": { + "values": { + "DIRECTION_UNSPECIFIED": 0, + "ASCENDING": 1, + "DESCENDING": 2 + } + } + } + }, + "Filter": { + "oneofs": { + "filterType": { + "oneof": [ + "compositeFilter", + "propertyFilter" + ] + } + }, + "fields": { + "compositeFilter": { + "type": "CompositeFilter", + "id": 1 + }, + "propertyFilter": { + "type": "PropertyFilter", + "id": 2 + } + } + }, + "CompositeFilter": { + "fields": { + "op": { + "type": "Operator", + "id": 1 + }, + "filters": { + "rule": "repeated", + "type": "Filter", + "id": 2 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "AND": 1, + "OR": 2 + } + } + } + }, + "PropertyFilter": { + "fields": { + "property": { + "type": "PropertyReference", + "id": 1 + }, + "op": { + "type": "Operator", + "id": 2 + }, + "value": { + "type": "Value", + "id": 3 + } + }, + "nested": { + "Operator": { + "values": { + "OPERATOR_UNSPECIFIED": 0, + "LESS_THAN": 1, + "LESS_THAN_OR_EQUAL": 2, + "GREATER_THAN": 3, + "GREATER_THAN_OR_EQUAL": 4, + "EQUAL": 5, + "IN": 6, + "NOT_EQUAL": 9, + "HAS_ANCESTOR": 11, + "NOT_IN": 13 + } + } + } + }, + "FindNearest": { + "fields": { + "vectorProperty": { + "type": "PropertyReference", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "queryVector": { + "type": "Value", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "distanceMeasure": { + "type": "DistanceMeasure", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "limit": { + "type": "google.protobuf.Int32Value", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "distanceResultProperty": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "distanceThreshold": { + "type": "google.protobuf.DoubleValue", + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "DistanceMeasure": { + "values": { + "DISTANCE_MEASURE_UNSPECIFIED": 0, + "EUCLIDEAN": 1, + "COSINE": 2, + "DOT_PRODUCT": 3 + } + } + } + }, + "GqlQuery": { + "fields": { + "queryString": { + "type": "string", + "id": 1 + }, + "allowLiterals": { + "type": "bool", + "id": 2 + }, + "namedBindings": { + "keyType": "string", + "type": "GqlQueryParameter", + "id": 5 + }, + "positionalBindings": { + "rule": "repeated", + "type": "GqlQueryParameter", + "id": 4 + } + } + }, + "GqlQueryParameter": { + "oneofs": { + "parameterType": { + "oneof": [ + "value", + "cursor" + ] + } + }, + "fields": { + "value": { + "type": "Value", + "id": 2 + }, + "cursor": { + "type": "bytes", + "id": 3 + } + } + }, + "QueryResultBatch": { + "fields": { + "skippedResults": { + "type": "int32", + "id": 6 + }, + "skippedCursor": { + "type": "bytes", + "id": 3 + }, + "entityResultType": { + "type": "EntityResult.ResultType", + "id": 1 + }, + "entityResults": { + "rule": "repeated", + "type": "EntityResult", + "id": 2 + }, + "endCursor": { + "type": "bytes", + "id": 4 + }, + "moreResults": { + "type": "MoreResultsType", + "id": 5 + }, + "snapshotVersion": { + "type": "int64", + "id": 7 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 8 + } + }, + "nested": { + "MoreResultsType": { + "values": { + "MORE_RESULTS_TYPE_UNSPECIFIED": 0, + "NOT_FINISHED": 1, + "MORE_RESULTS_AFTER_LIMIT": 2, + "MORE_RESULTS_AFTER_CURSOR": 4, + "NO_MORE_RESULTS": 3 + } + } + } + }, + "Datastore": { + "options": { + "(google.api.default_host)": "datastore.googleapis.com", + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastore" + }, + "methods": { + "Lookup": { + "requestType": "LookupRequest", + "responseType": "LookupResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:lookup", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", + "(google.api.method_signature)": "project_id,read_options,keys" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:lookup", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, + { + "(google.api.method_signature)": "project_id,read_options,keys" + } + ] + }, + "RunQuery": { + "requestType": "RunQueryRequest", + "responseType": "RunQueryResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:runQuery", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:runQuery", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + } + ] + }, + "RunAggregationQuery": { + "requestType": "RunAggregationQueryRequest", + "responseType": "RunAggregationQueryResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:runAggregationQuery", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:runAggregationQuery", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + } + ] + }, + "BeginTransaction": { + "requestType": "BeginTransactionRequest", + "responseType": "BeginTransactionResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:beginTransaction", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", + "(google.api.method_signature)": "project_id" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:beginTransaction", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, + { + "(google.api.method_signature)": "project_id" + } + ] + }, + "Commit": { + "requestType": "CommitRequest", + "responseType": "CommitResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:commit", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", + "(google.api.method_signature)": "project_id,mode,mutations" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:commit", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, + { + "(google.api.method_signature)": "project_id,mode,transaction,mutations" + }, + { + "(google.api.method_signature)": "project_id,mode,mutations" + } + ] + }, + "Rollback": { + "requestType": "RollbackRequest", + "responseType": "RollbackResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:rollback", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", + "(google.api.method_signature)": "project_id,transaction" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:rollback", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, + { + "(google.api.method_signature)": "project_id,transaction" + } + ] + }, + "AllocateIds": { + "requestType": "AllocateIdsRequest", + "responseType": "AllocateIdsResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:allocateIds", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", + "(google.api.method_signature)": "project_id,keys" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:allocateIds", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, + { + "(google.api.method_signature)": "project_id,keys" + } + ] + }, + "ReserveIds": { + "requestType": "ReserveIdsRequest", + "responseType": "ReserveIdsResponse", + "options": { + "(google.api.http).post": "/v1/projects/{project_id}:reserveIds", + "(google.api.http).body": "*", + "(google.api.routing).routing_parameters.field": "database_id", + "(google.api.method_signature)": "project_id,keys" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/projects/{project_id}:reserveIds", + "body": "*" + } + }, + { + "(google.api.routing)": { + "routing_parameters": [ + { + "field": "project_id" + }, + { + "field": "database_id" + } + ] + } + }, + { + "(google.api.method_signature)": "project_id,keys" + } + ] + } + } + }, + "LookupRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "readOptions": { + "type": "ReadOptions", + "id": 1 + }, + "keys": { + "rule": "repeated", + "type": "Key", + "id": 3, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "propertyMask": { + "type": "PropertyMask", + "id": 5 + } + } + }, + "LookupResponse": { + "fields": { + "found": { + "rule": "repeated", + "type": "EntityResult", + "id": 1 + }, + "missing": { + "rule": "repeated", + "type": "EntityResult", + "id": 2 + }, + "deferred": { + "rule": "repeated", + "type": "Key", + "id": 3 + }, + "transaction": { + "type": "bytes", + "id": 5 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 7 + } + } + }, + "RunQueryRequest": { + "oneofs": { + "queryType": { + "oneof": [ + "query", + "gqlQuery" + ] + } + }, + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "partitionId": { + "type": "PartitionId", + "id": 2 + }, + "readOptions": { + "type": "ReadOptions", + "id": 1 + }, + "query": { + "type": "Query", + "id": 3 + }, + "gqlQuery": { + "type": "GqlQuery", + "id": 7 + }, + "propertyMask": { + "type": "PropertyMask", + "id": 10 + }, + "explainOptions": { + "type": "ExplainOptions", + "id": 12, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "RunQueryResponse": { + "fields": { + "batch": { + "type": "QueryResultBatch", + "id": 1 + }, + "query": { + "type": "Query", + "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 + }, + "explainMetrics": { + "type": "ExplainMetrics", + "id": 9 + } + } + }, + "RunAggregationQueryRequest": { + "oneofs": { + "queryType": { + "oneof": [ + "aggregationQuery", + "gqlQuery" + ] + } + }, + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "partitionId": { + "type": "PartitionId", + "id": 2 + }, + "readOptions": { + "type": "ReadOptions", + "id": 1 + }, + "aggregationQuery": { + "type": "AggregationQuery", + "id": 3 + }, + "gqlQuery": { + "type": "GqlQuery", + "id": 7 + }, + "explainOptions": { + "type": "ExplainOptions", + "id": 11, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "RunAggregationQueryResponse": { + "fields": { + "batch": { + "type": "AggregationResultBatch", + "id": 1 + }, + "query": { + "type": "AggregationQuery", + "id": 2 + }, + "transaction": { + "type": "bytes", + "id": 5 + }, + "explainMetrics": { + "type": "ExplainMetrics", + "id": 9 + } + } + }, + "BeginTransactionRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "transactionOptions": { + "type": "TransactionOptions", + "id": 10 + } + } + }, + "BeginTransactionResponse": { + "fields": { + "transaction": { + "type": "bytes", + "id": 1 + } + } + }, + "RollbackRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "transaction": { + "type": "bytes", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "RollbackResponse": { + "fields": {} + }, + "CommitRequest": { + "oneofs": { + "transactionSelector": { + "oneof": [ + "transaction", + "singleUseTransaction" + ] + } + }, + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "mode": { + "type": "Mode", + "id": 5 + }, + "transaction": { + "type": "bytes", + "id": 1 + }, + "singleUseTransaction": { + "type": "TransactionOptions", + "id": 10 + }, + "mutations": { + "rule": "repeated", + "type": "Mutation", + "id": 6 + } + }, + "nested": { + "Mode": { + "values": { + "MODE_UNSPECIFIED": 0, + "TRANSACTIONAL": 1, + "NON_TRANSACTIONAL": 2 + } + } + } + }, + "CommitResponse": { + "fields": { + "mutationResults": { + "rule": "repeated", + "type": "MutationResult", + "id": 3 + }, + "indexUpdates": { + "type": "int32", + "id": 4 + }, + "commitTime": { + "type": "google.protobuf.Timestamp", + "id": 8 + } + } + }, + "AllocateIdsRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "keys": { + "rule": "repeated", + "type": "Key", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "AllocateIdsResponse": { + "fields": { + "keys": { + "rule": "repeated", + "type": "Key", + "id": 1 + } + } + }, + "ReserveIdsRequest": { + "fields": { + "projectId": { + "type": "string", + "id": 8, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "databaseId": { + "type": "string", + "id": 9 + }, + "keys": { + "rule": "repeated", + "type": "Key", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, + "ReserveIdsResponse": { + "fields": {} + }, + "Mutation": { + "oneofs": { + "operation": { + "oneof": [ + "insert", + "update", + "upsert", + "delete" + ] + }, + "conflictDetectionStrategy": { + "oneof": [ + "baseVersion", + "updateTime" + ] + } + }, + "fields": { + "insert": { + "type": "Entity", + "id": 4 + }, + "update": { + "type": "Entity", + "id": 5 + }, + "upsert": { + "type": "Entity", + "id": 6 + }, + "delete": { + "type": "Key", + "id": 7 + }, + "baseVersion": { + "type": "int64", + "id": 8 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 11 + }, + "conflictResolutionStrategy": { + "type": "ConflictResolutionStrategy", + "id": 10 + }, + "propertyMask": { + "type": "PropertyMask", + "id": 9 + }, + "propertyTransforms": { + "rule": "repeated", + "type": "PropertyTransform", + "id": 12, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "ConflictResolutionStrategy": { + "values": { + "STRATEGY_UNSPECIFIED": 0, + "SERVER_VALUE": 1, + "FAIL": 3 + } + } + } + }, + "PropertyTransform": { + "oneofs": { + "transformType": { + "oneof": [ + "setToServerValue", + "increment", + "maximum", + "minimum", + "appendMissingElements", + "removeAllFromArray" + ] + } + }, + "fields": { + "property": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "setToServerValue": { + "type": "ServerValue", + "id": 2 + }, + "increment": { + "type": "Value", + "id": 3 + }, + "maximum": { + "type": "Value", + "id": 4 + }, + "minimum": { + "type": "Value", + "id": 5 + }, + "appendMissingElements": { + "type": "ArrayValue", + "id": 6 + }, + "removeAllFromArray": { + "type": "ArrayValue", + "id": 7 + } + }, + "nested": { + "ServerValue": { + "values": { + "SERVER_VALUE_UNSPECIFIED": 0, + "REQUEST_TIME": 1 + } + } + } + }, + "MutationResult": { + "fields": { + "key": { + "type": "Key", + "id": 3 + }, + "version": { + "type": "int64", + "id": 4 + }, + "createTime": { + "type": "google.protobuf.Timestamp", + "id": 7 + }, + "updateTime": { + "type": "google.protobuf.Timestamp", + "id": 6 + }, + "conflictDetected": { + "type": "bool", + "id": 5 + }, + "transformResults": { + "rule": "repeated", + "type": "Value", + "id": 8 + } + } + }, + "PropertyMask": { + "fields": { + "paths": { + "rule": "repeated", + "type": "string", + "id": 1 + } + } + }, + "ReadOptions": { + "oneofs": { + "consistencyType": { + "oneof": [ + "readConsistency", + "transaction", + "newTransaction", + "readTime" + ] + } + }, + "fields": { + "readConsistency": { + "type": "ReadConsistency", + "id": 1 + }, + "transaction": { + "type": "bytes", + "id": 2 + }, + "newTransaction": { + "type": "TransactionOptions", + "id": 3 + }, + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 4 + } + }, + "nested": { + "ReadConsistency": { + "values": { + "READ_CONSISTENCY_UNSPECIFIED": 0, + "STRONG": 1, + "EVENTUAL": 2 + } + } + } + }, + "TransactionOptions": { + "oneofs": { + "mode": { + "oneof": [ + "readWrite", + "readOnly" + ] + } + }, + "fields": { + "readWrite": { + "type": "ReadWrite", + "id": 1 + }, + "readOnly": { + "type": "ReadOnly", + "id": 2 + } + }, + "nested": { + "ReadWrite": { + "fields": { + "previousTransaction": { + "type": "bytes", + "id": 1 + } + } + }, + "ReadOnly": { + "fields": { + "readTime": { + "type": "google.protobuf.Timestamp", + "id": 1 + } + } + } + } + }, + "ExplainOptions": { + "fields": { + "analyze": { + "type": "bool", + "id": 1, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + } + }, + "ExplainMetrics": { + "fields": { + "planSummary": { + "type": "PlanSummary", + "id": 1 + }, + "executionStats": { + "type": "ExecutionStats", + "id": 2 + } + } + }, + "PlanSummary": { + "fields": { + "indexesUsed": { + "rule": "repeated", + "type": "google.protobuf.Struct", + "id": 1 + } + } + }, + "ExecutionStats": { + "fields": { + "resultsReturned": { + "type": "int64", + "id": 1 + }, + "executionDuration": { + "type": "google.protobuf.Duration", + "id": 3 + }, + "readOperations": { + "type": "int64", + "id": 4 + }, + "debugStats": { + "type": "google.protobuf.Struct", + "id": 5 + } + } + } + } + } + } + }, + "api": { + "options": { + "go_package": "google.golang.org/genproto/googleapis/api/annotations;annotations", + "java_multiple_files": true, + "java_outer_classname": "RoutingProto", + "java_package": "com.google.api", + "objc_class_prefix": "GAPI" + }, + "nested": { + "http": { + "type": "HttpRule", + "id": 72295728, + "extend": "google.protobuf.MethodOptions" + }, + "Http": { + "fields": { + "rules": { + "rule": "repeated", + "type": "HttpRule", + "id": 1 + }, + "fullyDecodeReservedExpansion": { + "type": "bool", + "id": 2 + } + } + }, + "HttpRule": { + "oneofs": { + "pattern": { + "oneof": [ + "get", + "put", + "post", + "delete", + "patch", + "custom" + ] + } + }, + "fields": { + "selector": { + "type": "string", + "id": 1 + }, + "get": { + "type": "string", + "id": 2 + }, + "put": { + "type": "string", + "id": 3 + }, + "post": { + "type": "string", + "id": 4 + }, + "delete": { + "type": "string", + "id": 5 + }, + "patch": { + "type": "string", + "id": 6 + }, + "custom": { + "type": "CustomHttpPattern", + "id": 8 + }, + "body": { + "type": "string", + "id": 7 + }, + "responseBody": { + "type": "string", + "id": 12 + }, + "additionalBindings": { + "rule": "repeated", + "type": "HttpRule", + "id": 11 + } + } + }, + "CustomHttpPattern": { + "fields": { + "kind": { + "type": "string", + "id": 1 + }, + "path": { + "type": "string", + "id": 2 + } + } + }, + "methodSignature": { + "rule": "repeated", + "type": "string", + "id": 1051, + "extend": "google.protobuf.MethodOptions" + }, + "defaultHost": { + "type": "string", + "id": 1049, + "extend": "google.protobuf.ServiceOptions" + }, + "oauthScopes": { + "type": "string", + "id": 1050, + "extend": "google.protobuf.ServiceOptions" + }, + "apiVersion": { + "type": "string", + "id": 525000001, + "extend": "google.protobuf.ServiceOptions" + }, + "CommonLanguageSettings": { + "fields": { + "referenceDocsUri": { + "type": "string", + "id": 1, + "options": { + "deprecated": true + } + }, + "destinations": { + "rule": "repeated", + "type": "ClientLibraryDestination", + "id": 2 + }, + "selectiveGapicGeneration": { + "type": "SelectiveGapicGeneration", + "id": 3 + } + } + }, + "ClientLibrarySettings": { + "fields": { + "version": { + "type": "string", + "id": 1 + }, + "launchStage": { + "type": "LaunchStage", + "id": 2 + }, + "restNumericEnums": { + "type": "bool", + "id": 3 + }, + "javaSettings": { + "type": "JavaSettings", + "id": 21 + }, + "cppSettings": { + "type": "CppSettings", + "id": 22 + }, + "phpSettings": { + "type": "PhpSettings", + "id": 23 + }, + "pythonSettings": { + "type": "PythonSettings", + "id": 24 + }, + "nodeSettings": { + "type": "NodeSettings", + "id": 25 + }, + "dotnetSettings": { + "type": "DotnetSettings", + "id": 26 + }, + "rubySettings": { + "type": "RubySettings", + "id": 27 + }, + "goSettings": { + "type": "GoSettings", + "id": 28 + } + } + }, + "Publishing": { + "fields": { + "methodSettings": { + "rule": "repeated", + "type": "MethodSettings", + "id": 2 + }, + "newIssueUri": { + "type": "string", + "id": 101 + }, + "documentationUri": { + "type": "string", + "id": 102 + }, + "apiShortName": { + "type": "string", + "id": 103 + }, + "githubLabel": { + "type": "string", + "id": 104 + }, + "codeownerGithubTeams": { + "rule": "repeated", + "type": "string", + "id": 105 + }, + "docTagPrefix": { + "type": "string", + "id": 106 + }, + "organization": { + "type": "ClientLibraryOrganization", + "id": 107 + }, + "librarySettings": { + "rule": "repeated", + "type": "ClientLibrarySettings", + "id": 109 + }, + "protoReferenceDocumentationUri": { + "type": "string", + "id": 110 + }, + "restReferenceDocumentationUri": { + "type": "string", + "id": 111 + } + } + }, + "JavaSettings": { + "fields": { + "libraryPackage": { + "type": "string", + "id": 1 + }, + "serviceClassNames": { + "keyType": "string", + "type": "string", + "id": 2 + }, + "common": { + "type": "CommonLanguageSettings", + "id": 3 + } + } + }, + "CppSettings": { + "fields": { + "common": { + "type": "CommonLanguageSettings", + "id": 1 + } + } + }, + "PhpSettings": { + "fields": { + "common": { + "type": "CommonLanguageSettings", + "id": 1 + } + } + }, + "PythonSettings": { + "fields": { + "common": { + "type": "CommonLanguageSettings", + "id": 1 + }, + "experimentalFeatures": { + "type": "ExperimentalFeatures", + "id": 2 + } + }, + "nested": { + "ExperimentalFeatures": { + "fields": { + "restAsyncIoEnabled": { + "type": "bool", + "id": 1 + }, + "protobufPythonicTypesEnabled": { + "type": "bool", + "id": 2 + }, + "unversionedPackageDisabled": { + "type": "bool", + "id": 3 + } + } + } + } + }, + "NodeSettings": { + "fields": { + "common": { + "type": "CommonLanguageSettings", + "id": 1 + } + } + }, + "DotnetSettings": { + "fields": { + "common": { + "type": "CommonLanguageSettings", + "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 + }, + "renamedResources": { + "keyType": "string", + "type": "string", + "id": 3 + }, + "ignoredResources": { + "rule": "repeated", + "type": "string", + "id": 4 + }, + "forcedNamespaceAliases": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "handwrittenSignatures": { + "rule": "repeated", + "type": "string", + "id": 6 + } + } + }, + "RubySettings": { + "fields": { + "common": { + "type": "CommonLanguageSettings", + "id": 1 + } + } + }, + "GoSettings": { + "fields": { + "common": { + "type": "CommonLanguageSettings", + "id": 1 + }, + "renamedServices": { + "keyType": "string", + "type": "string", + "id": 2 + } + } + }, + "MethodSettings": { + "fields": { + "selector": { + "type": "string", + "id": 1 + }, + "longRunning": { + "type": "LongRunning", + "id": 2 + }, + "autoPopulatedFields": { + "rule": "repeated", + "type": "string", + "id": 3 + } + }, + "nested": { + "LongRunning": { + "fields": { + "initialPollDelay": { + "type": "google.protobuf.Duration", + "id": 1 + }, + "pollDelayMultiplier": { + "type": "float", + "id": 2 + }, + "maxPollDelay": { + "type": "google.protobuf.Duration", + "id": 3 + }, + "totalPollTimeout": { + "type": "google.protobuf.Duration", + "id": 4 + } + } + } + } + }, + "ClientLibraryOrganization": { + "values": { + "CLIENT_LIBRARY_ORGANIZATION_UNSPECIFIED": 0, + "CLOUD": 1, + "ADS": 2, + "PHOTOS": 3, + "STREET_VIEW": 4, + "SHOPPING": 5, + "GEO": 6, + "GENERATIVE_AI": 7 + } + }, + "ClientLibraryDestination": { + "values": { + "CLIENT_LIBRARY_DESTINATION_UNSPECIFIED": 0, + "GITHUB": 10, + "PACKAGE_MANAGER": 20 + } + }, + "SelectiveGapicGeneration": { + "fields": { + "methods": { + "rule": "repeated", + "type": "string", + "id": 1 + }, + "generateOmittedAsInternal": { + "type": "bool", + "id": 2 + } + } + }, + "LaunchStage": { + "values": { + "LAUNCH_STAGE_UNSPECIFIED": 0, + "UNIMPLEMENTED": 6, + "PRELAUNCH": 7, + "EARLY_ACCESS": 1, + "ALPHA": 2, + "BETA": 3, + "GA": 4, + "DEPRECATED": 5 + } + }, + "fieldBehavior": { + "rule": "repeated", + "type": "google.api.FieldBehavior", + "id": 1052, + "extend": "google.protobuf.FieldOptions", + "options": { + "packed": false + } + }, + "FieldBehavior": { + "values": { + "FIELD_BEHAVIOR_UNSPECIFIED": 0, + "OPTIONAL": 1, + "REQUIRED": 2, + "OUTPUT_ONLY": 3, + "INPUT_ONLY": 4, + "IMMUTABLE": 5, + "UNORDERED_LIST": 6, + "NON_EMPTY_DEFAULT": 7, + "IDENTIFIER": 8 + } + }, + "routing": { + "type": "google.api.RoutingRule", + "id": 72295729, + "extend": "google.protobuf.MethodOptions" + }, + "RoutingRule": { + "fields": { + "routingParameters": { + "rule": "repeated", + "type": "RoutingParameter", + "id": 2 + } + } + }, + "RoutingParameter": { + "fields": { + "field": { + "type": "string", + "id": 1 + }, + "pathTemplate": { + "type": "string", + "id": 2 + } + } + } + } + }, + "protobuf": { + "options": { + "go_package": "google.golang.org/protobuf/types/descriptorpb", + "java_package": "com.google.protobuf", + "java_outer_classname": "DescriptorProtos", + "csharp_namespace": "Google.Protobuf.Reflection", + "objc_class_prefix": "GPB", + "cc_enable_arenas": true, + "optimize_for": "SPEED" + }, + "nested": { + "FileDescriptorSet": { + "fields": { + "file": { + "rule": "repeated", + "type": "FileDescriptorProto", + "id": 1 + } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ] + }, + "Edition": { + "values": { + "EDITION_UNKNOWN": 0, + "EDITION_LEGACY": 900, + "EDITION_PROTO2": 998, + "EDITION_PROTO3": 999, + "EDITION_2023": 1000, + "EDITION_2024": 1001, + "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, + "EDITION_MAX": 2147483647 + } + }, + "FileDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "package": { + "type": "string", + "id": 2 + }, + "dependency": { + "rule": "repeated", + "type": "string", + "id": 3 + }, + "publicDependency": { + "rule": "repeated", + "type": "int32", + "id": 10, + "options": { + "packed": false + } + }, + "weakDependency": { + "rule": "repeated", + "type": "int32", + "id": 11, + "options": { + "packed": false + } + }, + "optionDependency": { + "rule": "repeated", + "type": "string", + "id": 15 + }, + "messageType": { + "rule": "repeated", + "type": "DescriptorProto", + "id": 4 + }, + "enumType": { + "rule": "repeated", + "type": "EnumDescriptorProto", + "id": 5 + }, + "service": { + "rule": "repeated", + "type": "ServiceDescriptorProto", + "id": 6 + }, + "extension": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 7 + }, + "options": { + "type": "FileOptions", + "id": 8 + }, + "sourceCodeInfo": { + "type": "SourceCodeInfo", + "id": 9 + }, + "syntax": { + "type": "string", + "id": 12 + }, + "edition": { + "type": "Edition", + "id": 14 + } + } + }, + "DescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "field": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 2 + }, + "extension": { + "rule": "repeated", + "type": "FieldDescriptorProto", + "id": 6 + }, + "nestedType": { + "rule": "repeated", + "type": "DescriptorProto", + "id": 3 + }, + "enumType": { + "rule": "repeated", + "type": "EnumDescriptorProto", + "id": 4 + }, + "extensionRange": { + "rule": "repeated", + "type": "ExtensionRange", + "id": 5 + }, + "oneofDecl": { + "rule": "repeated", + "type": "OneofDescriptorProto", + "id": 8 + }, + "options": { + "type": "MessageOptions", + "id": 7 + }, + "reservedRange": { + "rule": "repeated", + "type": "ReservedRange", + "id": 9 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 10 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 11 + } + }, + "nested": { + "ExtensionRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + }, + "options": { + "type": "ExtensionRangeOptions", + "id": 3 + } + } + }, + "ReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } + } + } + }, + "ExtensionRangeOptions": { + "fields": { + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + }, + "declaration": { + "rule": "repeated", + "type": "Declaration", + "id": 2, + "options": { + "retention": "RETENTION_SOURCE" + } + }, + "features": { + "type": "FeatureSet", + "id": 50 + }, + "verification": { + "type": "VerificationState", + "id": 3, + "options": { + "default": "UNVERIFIED", + "retention": "RETENTION_SOURCE" + } + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "nested": { + "Declaration": { + "fields": { + "number": { + "type": "int32", + "id": 1 + }, + "fullName": { + "type": "string", + "id": 2 + }, + "type": { + "type": "string", + "id": 3 + }, + "reserved": { + "type": "bool", + "id": 5 + }, + "repeated": { + "type": "bool", + "id": 6 + } + }, + "reserved": [ + [ + 4, + 4 + ] + ] + }, + "VerificationState": { + "values": { + "DECLARATION": 0, + "UNVERIFIED": 1 + } + } + } + }, + "FieldDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "number": { + "type": "int32", + "id": 3 + }, + "label": { + "type": "Label", + "id": 4 + }, + "type": { + "type": "Type", + "id": 5 + }, + "typeName": { + "type": "string", + "id": 6 + }, + "extendee": { + "type": "string", + "id": 2 + }, + "defaultValue": { + "type": "string", + "id": 7 + }, + "oneofIndex": { + "type": "int32", + "id": 9 + }, + "jsonName": { + "type": "string", + "id": 10 + }, + "options": { + "type": "FieldOptions", + "id": 8 + }, + "proto3Optional": { + "type": "bool", + "id": 17 + } + }, + "nested": { + "Type": { + "values": { + "TYPE_DOUBLE": 1, + "TYPE_FLOAT": 2, + "TYPE_INT64": 3, + "TYPE_UINT64": 4, + "TYPE_INT32": 5, + "TYPE_FIXED64": 6, + "TYPE_FIXED32": 7, + "TYPE_BOOL": 8, + "TYPE_STRING": 9, + "TYPE_GROUP": 10, + "TYPE_MESSAGE": 11, + "TYPE_BYTES": 12, + "TYPE_UINT32": 13, + "TYPE_ENUM": 14, + "TYPE_SFIXED32": 15, + "TYPE_SFIXED64": 16, + "TYPE_SINT32": 17, + "TYPE_SINT64": 18 + } + }, + "Label": { + "values": { + "LABEL_OPTIONAL": 1, + "LABEL_REPEATED": 3, + "LABEL_REQUIRED": 2 + } + } + } + }, + "OneofDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "options": { + "type": "OneofOptions", + "id": 2 + } + } + }, + "EnumDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "value": { + "rule": "repeated", + "type": "EnumValueDescriptorProto", + "id": 2 + }, + "options": { + "type": "EnumOptions", + "id": 3 + }, + "reservedRange": { + "rule": "repeated", + "type": "EnumReservedRange", + "id": 4 + }, + "reservedName": { + "rule": "repeated", + "type": "string", + "id": 5 + }, + "visibility": { + "type": "SymbolVisibility", + "id": 6 + } + }, + "nested": { + "EnumReservedRange": { + "fields": { + "start": { + "type": "int32", + "id": 1 + }, + "end": { + "type": "int32", + "id": 2 + } + } + } + } + }, + "EnumValueDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "number": { + "type": "int32", + "id": 2 + }, + "options": { + "type": "EnumValueOptions", + "id": 3 + } + } + }, + "ServiceDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "method": { + "rule": "repeated", + "type": "MethodDescriptorProto", + "id": 2 + }, + "options": { + "type": "ServiceOptions", + "id": 3 + } + } + }, + "MethodDescriptorProto": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "inputType": { + "type": "string", + "id": 2 + }, + "outputType": { + "type": "string", + "id": 3 + }, + "options": { + "type": "MethodOptions", + "id": 4 + }, + "clientStreaming": { + "type": "bool", + "id": 5, + "options": { + "default": false + } + }, + "serverStreaming": { + "type": "bool", + "id": 6, + "options": { + "default": false + } + } + } + }, + "FileOptions": { + "fields": { + "javaPackage": { + "type": "string", + "id": 1 + }, + "javaOuterClassname": { + "type": "string", + "id": 8 + }, + "javaMultipleFiles": { + "type": "bool", + "id": 10, + "options": { + "default": false + } + }, + "javaGenerateEqualsAndHash": { + "type": "bool", + "id": 20, + "options": { + "deprecated": true + } + }, + "javaStringCheckUtf8": { + "type": "bool", + "id": 27, + "options": { + "default": false + } + }, + "optimizeFor": { + "type": "OptimizeMode", + "id": 9, + "options": { + "default": "SPEED" + } + }, + "goPackage": { + "type": "string", + "id": 11 + }, + "ccGenericServices": { + "type": "bool", + "id": 16, + "options": { + "default": false + } + }, + "javaGenericServices": { + "type": "bool", + "id": 17, + "options": { + "default": false + } + }, + "pyGenericServices": { + "type": "bool", + "id": 18, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 23, + "options": { + "default": false + } + }, + "ccEnableArenas": { + "type": "bool", + "id": 31, + "options": { + "default": true + } + }, + "objcClassPrefix": { + "type": "string", + "id": 36 + }, + "csharpNamespace": { + "type": "string", + "id": 37 + }, + "swiftPrefix": { + "type": "string", + "id": 39 + }, + "phpClassPrefix": { + "type": "string", + "id": 40 + }, + "phpNamespace": { + "type": "string", + "id": 41 + }, + "phpMetadataNamespace": { + "type": "string", + "id": 44 + }, + "rubyPackage": { + "type": "string", + "id": 45 + }, + "features": { + "type": "FeatureSet", + "id": 50 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 42, + 42 + ], + "php_generic_services", + [ + 38, + 38 + ] + ], + "nested": { + "OptimizeMode": { + "values": { + "SPEED": 1, + "CODE_SIZE": 2, + "LITE_RUNTIME": 3 + } + } + } + }, + "MessageOptions": { + "fields": { + "messageSetWireFormat": { + "type": "bool", + "id": 1, + "options": { + "default": false + } + }, + "noStandardDescriptorAccessor": { + "type": "bool", + "id": 2, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "mapEntry": { + "type": "bool", + "id": 7 + }, + "deprecatedLegacyJsonFieldConflicts": { + "type": "bool", + "id": 11, + "options": { + "deprecated": true + } + }, + "features": { + "type": "FeatureSet", + "id": 12 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 4, + 4 + ], + [ + 5, + 5 + ], + [ + 6, + 6 + ], + [ + 8, + 8 + ], + [ + 9, + 9 + ] + ] + }, + "FieldOptions": { + "fields": { + "ctype": { + "type": "CType", + "id": 1, + "options": { + "default": "STRING" + } + }, + "packed": { + "type": "bool", + "id": 2 + }, + "jstype": { + "type": "JSType", + "id": 6, + "options": { + "default": "JS_NORMAL" + } + }, + "lazy": { + "type": "bool", + "id": 5, + "options": { + "default": false + } + }, + "unverifiedLazy": { + "type": "bool", + "id": 15, + "options": { + "default": false + } + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "weak": { + "type": "bool", + "id": 10, + "options": { + "default": false, + "deprecated": true + } + }, + "debugRedact": { + "type": "bool", + "id": 16, + "options": { + "default": false + } + }, + "retention": { + "type": "OptionRetention", + "id": 17 + }, + "targets": { + "rule": "repeated", + "type": "OptionTargetType", + "id": 19, + "options": { + "packed": false + } + }, + "editionDefaults": { + "rule": "repeated", + "type": "EditionDefault", + "id": 20 + }, + "features": { + "type": "FeatureSet", + "id": 21 + }, + "featureSupport": { + "type": "FeatureSupport", + "id": 22 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 4, + 4 + ], + [ + 18, + 18 + ] + ], + "nested": { + "CType": { + "values": { + "STRING": 0, + "CORD": 1, + "STRING_PIECE": 2 + } + }, + "JSType": { + "values": { + "JS_NORMAL": 0, + "JS_STRING": 1, + "JS_NUMBER": 2 + } + }, + "OptionRetention": { + "values": { + "RETENTION_UNKNOWN": 0, + "RETENTION_RUNTIME": 1, + "RETENTION_SOURCE": 2 + } + }, + "OptionTargetType": { + "values": { + "TARGET_TYPE_UNKNOWN": 0, + "TARGET_TYPE_FILE": 1, + "TARGET_TYPE_EXTENSION_RANGE": 2, + "TARGET_TYPE_MESSAGE": 3, + "TARGET_TYPE_FIELD": 4, + "TARGET_TYPE_ONEOF": 5, + "TARGET_TYPE_ENUM": 6, + "TARGET_TYPE_ENUM_ENTRY": 7, + "TARGET_TYPE_SERVICE": 8, + "TARGET_TYPE_METHOD": 9 + } + }, + "EditionDefault": { + "fields": { + "edition": { + "type": "Edition", + "id": 3 + }, + "value": { + "type": "string", + "id": 2 + } + } + }, + "FeatureSupport": { + "fields": { + "editionIntroduced": { + "type": "Edition", + "id": 1 + }, + "editionDeprecated": { + "type": "Edition", + "id": 2 + }, + "deprecationWarning": { + "type": "string", + "id": 3 + }, + "editionRemoved": { + "type": "Edition", + "id": 4 + } + } + } + } + }, + "OneofOptions": { + "fields": { + "features": { + "type": "FeatureSet", + "id": 1 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "EnumOptions": { + "fields": { + "allowAlias": { + "type": "bool", + "id": 2 + }, + "deprecated": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "deprecatedLegacyJsonFieldConflicts": { + "type": "bool", + "id": 6, + "options": { + "deprecated": true + } + }, + "features": { + "type": "FeatureSet", + "id": 7 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "reserved": [ + [ + 5, + 5 + ] + ] + }, + "EnumValueOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 1, + "options": { + "default": false + } + }, + "features": { + "type": "FeatureSet", + "id": 2 + }, + "debugRedact": { + "type": "bool", + "id": 3, + "options": { + "default": false + } + }, + "featureSupport": { + "type": "FieldOptions.FeatureSupport", + "id": 4 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "ServiceOptions": { + "fields": { + "features": { + "type": "FeatureSet", + "id": 34 + }, + "deprecated": { + "type": "bool", + "id": 33, + "options": { + "default": false + } + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ] + }, + "MethodOptions": { + "fields": { + "deprecated": { + "type": "bool", + "id": 33, + "options": { + "default": false + } + }, + "idempotencyLevel": { + "type": "IdempotencyLevel", + "id": 34, + "options": { + "default": "IDEMPOTENCY_UNKNOWN" + } + }, + "features": { + "type": "FeatureSet", + "id": 35 + }, + "uninterpretedOption": { + "rule": "repeated", + "type": "UninterpretedOption", + "id": 999 + } + }, + "extensions": [ + [ + 1000, + 536870911 + ] + ], + "nested": { + "IdempotencyLevel": { + "values": { + "IDEMPOTENCY_UNKNOWN": 0, + "NO_SIDE_EFFECTS": 1, + "IDEMPOTENT": 2 + } + } + } + }, + "UninterpretedOption": { + "fields": { + "name": { + "rule": "repeated", + "type": "NamePart", + "id": 2 + }, + "identifierValue": { + "type": "string", + "id": 3 + }, + "positiveIntValue": { + "type": "uint64", + "id": 4 + }, + "negativeIntValue": { + "type": "int64", + "id": 5 + }, + "doubleValue": { + "type": "double", + "id": 6 + }, + "stringValue": { + "type": "bytes", + "id": 7 + }, + "aggregateValue": { + "type": "string", + "id": 8 + } + }, + "nested": { + "NamePart": { + "fields": { + "namePart": { + "rule": "required", + "type": "string", + "id": 1 + }, + "isExtension": { + "rule": "required", + "type": "bool", + "id": 2 + } + } + } + } + }, + "FeatureSet": { + "fields": { + "fieldPresence": { + "type": "FieldPresence", + "id": 1, + "options": { + "retention": "RETENTION_RUNTIME", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_2023", + "edition_defaults.value": "EXPLICIT" + } + }, + "enumType": { + "type": "EnumType", + "id": 2, + "options": { + "retention": "RETENTION_RUNTIME", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_PROTO3", + "edition_defaults.value": "OPEN" + } + }, + "repeatedFieldEncoding": { + "type": "RepeatedFieldEncoding", + "id": 3, + "options": { + "retention": "RETENTION_RUNTIME", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_PROTO3", + "edition_defaults.value": "PACKED" + } + }, + "utf8Validation": { + "type": "Utf8Validation", + "id": 4, + "options": { + "retention": "RETENTION_RUNTIME", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_PROTO3", + "edition_defaults.value": "VERIFY" + } + }, + "messageEncoding": { + "type": "MessageEncoding", + "id": 5, + "options": { + "retention": "RETENTION_RUNTIME", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_LEGACY", + "edition_defaults.value": "LENGTH_PREFIXED" + } + }, + "jsonFormat": { + "type": "JsonFormat", + "id": 6, + "options": { + "retention": "RETENTION_RUNTIME", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2023", + "edition_defaults.edition": "EDITION_PROTO3", + "edition_defaults.value": "ALLOW" + } + }, + "enforceNamingStyle": { + "type": "EnforceNamingStyle", + "id": 7, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_METHOD", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "STYLE2024" + } + }, + "defaultSymbolVisibility": { + "type": "VisibilityFeature.DefaultSymbolVisibility", + "id": 8, + "options": { + "retention": "RETENTION_SOURCE", + "targets": "TARGET_TYPE_FILE", + "feature_support.edition_introduced": "EDITION_2024", + "edition_defaults.edition": "EDITION_2024", + "edition_defaults.value": "EXPORT_TOP_LEVEL" + } + } + }, + "extensions": [ + [ + 1000, + 9994 + ], + [ + 9995, + 9999 + ], + [ + 10000, + 10000 + ] + ], + "reserved": [ + [ + 999, + 999 + ] + ], + "nested": { + "FieldPresence": { + "values": { + "FIELD_PRESENCE_UNKNOWN": 0, + "EXPLICIT": 1, + "IMPLICIT": 2, + "LEGACY_REQUIRED": 3 + } + }, + "EnumType": { + "values": { + "ENUM_TYPE_UNKNOWN": 0, + "OPEN": 1, + "CLOSED": 2 + } + }, + "RepeatedFieldEncoding": { + "values": { + "REPEATED_FIELD_ENCODING_UNKNOWN": 0, + "PACKED": 1, + "EXPANDED": 2 + } + }, + "Utf8Validation": { + "values": { + "UTF8_VALIDATION_UNKNOWN": 0, + "VERIFY": 2, + "NONE": 3 + }, + "reserved": [ + [ + 1, + 1 + ] + ] + }, + "MessageEncoding": { + "values": { + "MESSAGE_ENCODING_UNKNOWN": 0, + "LENGTH_PREFIXED": 1, + "DELIMITED": 2 + } + }, + "JsonFormat": { + "values": { + "JSON_FORMAT_UNKNOWN": 0, + "ALLOW": 1, + "LEGACY_BEST_EFFORT": 2 + } + }, + "EnforceNamingStyle": { + "values": { + "ENFORCE_NAMING_STYLE_UNKNOWN": 0, + "STYLE2024": 1, + "STYLE_LEGACY": 2 + } + }, + "VisibilityFeature": { + "fields": {}, + "reserved": [ + [ + 1, + 536870911 + ] + ], + "nested": { + "DefaultSymbolVisibility": { + "values": { + "DEFAULT_SYMBOL_VISIBILITY_UNKNOWN": 0, + "EXPORT_ALL": 1, + "EXPORT_TOP_LEVEL": 2, + "LOCAL_ALL": 3, + "STRICT": 4 + } + } + } + } + } + }, + "FeatureSetDefaults": { + "fields": { + "defaults": { + "rule": "repeated", + "type": "FeatureSetEditionDefault", + "id": 1 + }, + "minimumEdition": { + "type": "Edition", + "id": 4 + }, + "maximumEdition": { + "type": "Edition", + "id": 5 + } + }, + "nested": { + "FeatureSetEditionDefault": { + "fields": { + "edition": { + "type": "Edition", + "id": 3 + }, + "overridableFeatures": { + "type": "FeatureSet", + "id": 4 + }, + "fixedFeatures": { + "type": "FeatureSet", + "id": 5 + } + }, + "reserved": [ + [ + 1, + 1 + ], + [ + 2, + 2 + ], + "features" + ] + } + } + }, + "SourceCodeInfo": { + "fields": { + "location": { + "rule": "repeated", + "type": "Location", + "id": 1 + } + }, + "extensions": [ + [ + 536000000, + 536000000 + ] + ], + "nested": { + "Location": { + "fields": { + "path": { + "rule": "repeated", + "type": "int32", + "id": 1 + }, + "span": { + "rule": "repeated", + "type": "int32", + "id": 2 + }, + "leadingComments": { + "type": "string", + "id": 3 + }, + "trailingComments": { + "type": "string", + "id": 4 + }, + "leadingDetachedComments": { + "rule": "repeated", + "type": "string", + "id": 6 + } + } + } + } + }, + "GeneratedCodeInfo": { + "fields": { + "annotation": { + "rule": "repeated", + "type": "Annotation", + "id": 1 + } + }, + "nested": { + "Annotation": { + "fields": { + "path": { + "rule": "repeated", + "type": "int32", + "id": 1 + }, + "sourceFile": { + "type": "string", + "id": 2 + }, + "begin": { + "type": "int32", + "id": 3 + }, + "end": { + "type": "int32", + "id": 4 + }, + "semantic": { + "type": "Semantic", + "id": 5 + } + }, + "nested": { + "Semantic": { + "values": { + "NONE": 0, + "SET": 1, + "ALIAS": 2 + } + } + } + } + } + }, + "SymbolVisibility": { + "values": { + "VISIBILITY_UNSET": 0, + "VISIBILITY_LOCAL": 1, + "VISIBILITY_EXPORT": 2 + } + }, + "Duration": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } + }, + "Any": { + "fields": { + "type_url": { + "type": "string", + "id": 1 + }, + "value": { + "type": "bytes", + "id": 2 + } + } + }, + "Empty": { + "fields": {} + }, + "Timestamp": { + "fields": { + "seconds": { + "type": "int64", + "id": 1 + }, + "nanos": { + "type": "int32", + "id": 2 + } + } + }, + "Struct": { + "fields": { + "fields": { + "keyType": "string", + "type": "Value", + "id": 1 + } + } + }, + "Value": { + "oneofs": { + "kind": { + "oneof": [ + "nullValue", + "numberValue", + "stringValue", + "boolValue", + "structValue", + "listValue" + ] + } + }, + "fields": { + "nullValue": { + "type": "NullValue", + "id": 1 + }, + "numberValue": { + "type": "double", + "id": 2 + }, + "stringValue": { + "type": "string", + "id": 3 + }, + "boolValue": { + "type": "bool", + "id": 4 + }, + "structValue": { + "type": "Struct", + "id": 5 + }, + "listValue": { + "type": "ListValue", + "id": 6 + } + } + }, + "NullValue": { + "values": { + "NULL_VALUE": 0 + } + }, + "ListValue": { + "fields": { + "values": { + "rule": "repeated", + "type": "Value", + "id": 1 + } + } + }, + "DoubleValue": { + "fields": { + "value": { + "type": "double", + "id": 1 + } + } + }, + "FloatValue": { + "fields": { + "value": { + "type": "float", + "id": 1 + } + } + }, + "Int64Value": { + "fields": { + "value": { + "type": "int64", + "id": 1 + } + } + }, + "UInt64Value": { + "fields": { + "value": { + "type": "uint64", + "id": 1 + } + } + }, + "Int32Value": { + "fields": { + "value": { + "type": "int32", + "id": 1 + } + } + }, + "UInt32Value": { + "fields": { + "value": { + "type": "uint32", + "id": 1 + } + } + }, + "BoolValue": { + "fields": { + "value": { + "type": "bool", + "id": 1 + } + } + }, + "StringValue": { + "fields": { + "value": { + "type": "string", + "id": 1 + } + } + }, + "BytesValue": { + "fields": { + "value": { + "type": "bytes", + "id": 1 + } + } + } + } + }, + "longrunning": { + "options": { + "cc_enable_arenas": true, + "csharp_namespace": "Google.LongRunning", + "go_package": "cloud.google.com/go/longrunning/autogen/longrunningpb;longrunningpb", + "java_multiple_files": true, + "java_outer_classname": "OperationsProto", + "java_package": "com.google.longrunning", + "objc_class_prefix": "GLRUN", + "php_namespace": "Google\\LongRunning" + }, + "nested": { + "operationInfo": { + "type": "google.longrunning.OperationInfo", + "id": 1049, + "extend": "google.protobuf.MethodOptions" + }, + "Operations": { + "options": { + "(google.api.default_host)": "longrunning.googleapis.com" + }, + "methods": { + "ListOperations": { + "requestType": "ListOperationsRequest", + "responseType": "ListOperationsResponse", + "options": { + "(google.api.http).get": "/v1/{name=operations}", + "(google.api.method_signature)": "name,filter" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=operations}" + } + }, + { + "(google.api.method_signature)": "name,filter" + } + ] + }, + "GetOperation": { + "requestType": "GetOperationRequest", + "responseType": "Operation", + "options": { + "(google.api.http).get": "/v1/{name=operations/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "get": "/v1/{name=operations/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "DeleteOperation": { + "requestType": "DeleteOperationRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).delete": "/v1/{name=operations/**}", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "delete": "/v1/{name=operations/**}" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "CancelOperation": { + "requestType": "CancelOperationRequest", + "responseType": "google.protobuf.Empty", + "options": { + "(google.api.http).post": "/v1/{name=operations/**}:cancel", + "(google.api.http).body": "*", + "(google.api.method_signature)": "name" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=operations/**}:cancel", + "body": "*" + } + }, + { + "(google.api.method_signature)": "name" + } + ] + }, + "WaitOperation": { + "requestType": "WaitOperationRequest", + "responseType": "Operation" + } + } + }, + "Operation": { + "oneofs": { + "result": { + "oneof": [ + "error", + "response" + ] + } + }, + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "metadata": { + "type": "google.protobuf.Any", + "id": 2 + }, + "done": { + "type": "bool", + "id": 3 + }, + "error": { + "type": "google.rpc.Status", + "id": 4 + }, + "response": { + "type": "google.protobuf.Any", + "id": 5 + } + } + }, + "GetOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + } + } + }, + "ListOperationsRequest": { + "fields": { + "name": { + "type": "string", + "id": 4 + }, + "filter": { + "type": "string", + "id": 1 + }, + "pageSize": { + "type": "int32", + "id": 2 + }, + "pageToken": { + "type": "string", + "id": 3 + } + } + }, + "ListOperationsResponse": { + "fields": { + "operations": { + "rule": "repeated", + "type": "Operation", + "id": 1 + }, + "nextPageToken": { + "type": "string", + "id": 2 + } + } + }, + "CancelOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + } + } + }, + "DeleteOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + } + } + }, + "WaitOperationRequest": { + "fields": { + "name": { + "type": "string", + "id": 1 + }, + "timeout": { + "type": "google.protobuf.Duration", + "id": 2 + } + } + }, + "OperationInfo": { + "fields": { + "responseType": { + "type": "string", + "id": 1 + }, + "metadataType": { + "type": "string", + "id": 2 + } + } + } + } + }, + "rpc": { + "options": { + "cc_enable_arenas": true, + "go_package": "google.golang.org/genproto/googleapis/rpc/status;status", + "java_multiple_files": true, + "java_outer_classname": "StatusProto", + "java_package": "com.google.rpc", + "objc_class_prefix": "RPC" + }, + "nested": { + "Status": { + "fields": { + "code": { + "type": "int32", + "id": 1 + }, + "message": { + "type": "string", + "id": 2 + }, + "details": { + "rule": "repeated", + "type": "google.protobuf.Any", + "id": 3 + } + } + } + } + }, + "type": { + "options": { + "cc_enable_arenas": true, + "go_package": "google.golang.org/genproto/googleapis/type/latlng;latlng", + "java_multiple_files": true, + "java_outer_classname": "LatLngProto", + "java_package": "com.google.type", + "objc_class_prefix": "GTP" + }, + "nested": { + "LatLng": { + "fields": { + "latitude": { + "type": "double", + "id": 1 + }, + "longitude": { + "type": "double", + "id": 2 + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/handwritten/nodejs-datastore/samples/.eslintrc.yml b/handwritten/nodejs-datastore/samples/.eslintrc.yml new file mode 100644 index 00000000000..aee43ae4b0a --- /dev/null +++ b/handwritten/nodejs-datastore/samples/.eslintrc.yml @@ -0,0 +1,4 @@ +--- +rules: + no-console: off + require-atomic-updates: off diff --git a/handwritten/nodejs-datastore/samples/README.md b/handwritten/nodejs-datastore/samples/README.md new file mode 100644 index 00000000000..2aa9dee6e6f --- /dev/null +++ b/handwritten/nodejs-datastore/samples/README.md @@ -0,0 +1,356 @@ +[//]: # "This README.md file is auto-generated, all changes to this file will be lost." +[//]: # "To regenerate it, use `python -m synthtool`." +Google Cloud Platform logo + +# [Google Cloud Datastore: Node.js Samples](https://github.com/googleapis/nodejs-datastore) + +[![Open in Cloud Shell][shell_img]][shell_link] + + + +## Table of Contents + +* [Before you begin](#before-you-begin) +* [Samples](#samples) + * [Concepts](#concepts) + * [Error](#error) + * [Export](#export) + * [Import](#import) + * [Indexes.get](#indexes.get) + * [Indexes.list](#indexes.list) + * [Create a union between two filters](#create-a-union-between-two-filters) + * [Run query explain (regular query)](#run-query-explain-regular-query) + * [Run query explain (aggregate query)](#run-query-explain-aggregate-query) + * [Run query explain analyze (regular query)](#run-query-explain-analyze-regular-query) + * [Run query explain analyze (aggregate query)](#run-query-explain-analyze-aggregate-query) + * [Quickstart](#quickstart) + * [Add Task](#add-task) + * [Delete Task](#delete-task) + * [Legacy Samples](#legacy-samples) + * [List Tasks](#list-tasks) + * [Update Task](#update-task) + +## Before you begin + +Before running the samples, make sure you've followed the steps outlined in +[Using the client library](https://github.com/googleapis/nodejs-datastore#using-the-client-library). + +`cd samples` + +`npm install` + +`cd ..` + +## Samples + + + +### Concepts + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/concepts.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/concepts.js,samples/README.md) + +__Usage:__ + + +`node samples/concepts.js` + + +----- + + + + +### Error + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/error.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/error.js,samples/README.md) + +__Usage:__ + + +`node samples/error.js` + + +----- + + + + +### Export + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/export.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/export.js,samples/README.md) + +__Usage:__ + + +`node samples/export.js` + + +----- + + + + +### Import + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/import.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/import.js,samples/README.md) + +__Usage:__ + + +`node samples/import.js` + + +----- + + + + +### Indexes.get + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/indexes.get.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/indexes.get.js,samples/README.md) + +__Usage:__ + + +`node samples/indexes.get.js` + + +----- + + + + +### Indexes.list + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/indexes.list.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/indexes.list.js,samples/README.md) + +__Usage:__ + + +`node samples/indexes.list.js` + + +----- + + + + +### Create a union between two filters + +Create a union between two filters (logical OR operator) + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryFilterOr.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryFilterOr.js,samples/README.md) + +__Usage:__ + + +`node samples/queryFilterOr.js` + + +----- + + + + +### Run query explain (regular query) + +Run query explain for a standard query and print query explain metrics + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplain.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplain.js,samples/README.md) + +__Usage:__ + + +`node samples/queryProfileExplain.js` + + +----- + + + + +### Run query explain (aggregate query) + +Run query explain for an aggregate query and print query explain metrics + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplainAggregation.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplainAggregation.js,samples/README.md) + +__Usage:__ + + +`node samples/queryProfileExplainAggregation.js` + + +----- + + + + +### Run query explain analyze (regular query) + +Run query explain analyze for a standard query and print query explain metrics + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplainAnalyze.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplainAnalyze.js,samples/README.md) + +__Usage:__ + + +`node samples/queryProfileExplainAnalyze.js` + + +----- + + + + +### Run query explain analyze (aggregate query) + +Run query explain analyze for an aggregate query and print query explain metrics + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/queryProfileExplainAnalyzeAggregation.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/queryProfileExplainAnalyzeAggregation.js,samples/README.md) + +__Usage:__ + + +`node samples/queryProfileExplainAnalyzeAggregation.js` + + +----- + + + + +### Quickstart + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/quickstart.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) + +__Usage:__ + + +`node samples/quickstart.js` + + +----- + + + + +### Add Task + +Adds a task with a description . + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.add.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.add.js,samples/README.md) + +__Usage:__ + + +`node tasks.add.js ` + + +----- + + + + +### Delete Task + +Deletes task . + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.delete.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.delete.js,samples/README.md) + +__Usage:__ + + +`node tasks.delete.js ` + + +----- + + + + +### Legacy Samples + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.js,samples/README.md) + +__Usage:__ + + +`node samples/tasks.js` + + +----- + + + + +### List Tasks + +Lists all tasks ordered by creation time. + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.list.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.list.js,samples/README.md) + +__Usage:__ + + +`node tasks.list.js` + + +----- + + + + +### Update Task + +Marks task as Done. + +View the [source code](https://github.com/googleapis/nodejs-datastore/blob/main/samples/tasks.markdone.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.markdone.js,samples/README.md) + +__Usage:__ + + +`node tasks.markdone.js ` + + + + + + +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png +[shell_link]: https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/README.md +[product-docs]: https://cloud.google.com/datastore/docs diff --git a/handwritten/nodejs-datastore/samples/concepts.js b/handwritten/nodejs-datastore/samples/concepts.js new file mode 100644 index 00000000000..78ebb544d48 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/concepts.js @@ -0,0 +1,1215 @@ +// Copyright 2017 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +const sinon = require('sinon'); +const assert = require('assert'); + +// By default, the client will authenticate using the service account file +// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use +// the project specified by the GCLOUD_PROJECT environment variable. See +// https://googlecloudplatform.github.io/gcloud-node/#/docs/google-cloud/latest/guides/authentication +const {Datastore, PropertyFilter, and} = require('@google-cloud/datastore'); + +function makeStub() { + return sinon.stub().returns(Promise.resolve([])); +} + +// This mock is used in the documentation snippets. +let datastore = { + delete: makeStub(), + get: makeStub(), + insert: makeStub(), + key: makeStub(), + update: makeStub(), + upsert: makeStub(), + runQuery: sinon.stub().returns(Promise.resolve([[]])), + save: makeStub(), +}; + +const namespace = `${Date.now()}`; +class TestHelper { + constructor(projectId) { + const options = { + projectId: projectId, + namespace, + }; + this.datastore = new Datastore(options); + } +} + +class Entity extends TestHelper { + constructor(projectId) { + super(projectId); + // To create the keys, we have to use this instance of Datastore. + datastore.key = this.datastore.key; + datastore.namespace = this.datastore.namespace; + + this.incompleteKey = this.getIncompleteKey(); + this.namedKey = this.getNamedKey(); + this.keyWithParent = this.getKeyWithParent(); + this.keyWithMultiLevelParent = this.getKeyWithMultiLevelParent(); + } + + getIncompleteKey() { + // [START datastore_incomplete_key] + const taskKey = datastore.key('Task'); + // [END datastore_incomplete_key] + + return taskKey; + } + + getNamedKey() { + // [START datastore_named_key] + const taskKey = datastore.key(['Task', 'sampleTask']); + // [END datastore_named_key] + + return taskKey; + } + + getKeyWithParent() { + // [START datastore_key_with_parent] + const taskKey = datastore.key([ + 'TaskList', + 'default', + 'Task', + 'sampleTask', + ]); + // [END datastore_key_with_parent] + + return taskKey; + } + + getKeyWithMultiLevelParent() { + // [START datastore_key_with_multilevel_parent] + const taskKey = datastore.key([ + 'User', + 'alice', + 'TaskList', + 'default', + 'Task', + 'sampleTask', + ]); + // [END datastore_key_with_multilevel_parent] + + return taskKey; + } + + getTask() { + // [START datastore_basic_entity] + const task = { + category: 'Personal', + done: false, + priority: 4, + description: 'Learn Cloud Datastore', + }; + // [END datastore_basic_entity] + + return task; + } + + testIncompleteKey() { + return this.datastore.save({ + key: this.incompleteKey, + data: {}, + }); + } + + testNamedKey() { + return this.datastore.save({ + key: this.namedKey, + data: {}, + }); + } + + testKeyWithParent() { + return this.datastore.save({ + key: this.keyWithParent, + data: {}, + }); + } + + testKeyWithMultiLevelParent() { + return this.datastore.save({ + key: this.keyWithMultiLevelParent, + data: {}, + }); + } + + testEntityWithParent() { + // [START datastore_entity_with_parent] + const taskKey = datastore.key([ + 'TaskList', + 'default', + 'Task', + 'sampleTask', + ]); + + const task = { + key: taskKey, + data: { + category: 'Personal', + done: false, + priority: 4, + description: 'Learn Cloud Datastore', + }, + }; + // [END datastore_entity_with_parent] + + return this.datastore.save(task); + } + + testProperties() { + // [START datastore_properties] + const task = [ + { + name: 'category', + value: 'Personal', + }, + { + name: 'created', + value: new Date(), + }, + { + name: 'done', + value: false, + }, + { + name: 'priority', + value: 4, + }, + { + name: 'percent_complete', + value: 10.0, + }, + { + name: 'description', + value: 'Learn Cloud Datastore', + excludeFromIndexes: true, + }, + ]; + // [END datastore_properties] + + return this.datastore.save({ + key: this.incompleteKey, + data: task, + }); + } + + testArrayValue() { + // [START datastore_array_value] + const task = { + tags: ['fun', 'programming'], + collaborators: ['alice', 'bob'], + }; + // [END datastore_array_value] + + return this.datastore.save({ + key: this.incompleteKey, + data: task, + }); + } + + testBasicEntity() { + return this.datastore.save({ + key: this.getIncompleteKey(), + data: this.getTask(), + }); + } + + async testUpsert() { + // [START datastore_upsert] + const taskKey = datastore.key('Task'); + const task = { + category: 'Personal', + done: false, + priority: 4, + description: 'Learn Cloud Datastore', + }; + + const entity = { + key: taskKey, + data: task, + }; + + await datastore.upsert(entity); + // Task inserted successfully. + // [END datastore_upsert] + + return this.datastore.upsert({ + key: this.datastore.key(['Task', 1]), + data: task, + }); + } + + testInsert() { + // [START datastore_insert] + const taskKey = datastore.key('Task'); + const task = { + category: 'Personal', + done: false, + priority: 4, + description: 'Learn Cloud Datastore', + }; + + const entity = { + key: taskKey, + data: task, + }; + + datastore.insert(entity).then(() => { + // Task inserted successfully. + }); + // [END datastore_insert] + + return this.datastore.save({ + method: 'insert', + key: taskKey, + data: task, + }); + } + + async testLookup() { + // [START datastore_lookup] + const taskKey = datastore.key('Task'); + const [entity] = await datastore.get(taskKey); + // entity = { + // category: 'Personal', + // done: false, + // priority: 4, + // description: 'Learn Cloud Datastore', + // [Symbol(KEY)]: + // Key { + // namespace: undefined, + // id: '...', + // kind: 'Task', + // path: [Getter] + // } + // } + // }; + console.log(entity); + // [END datastore_lookup] + await this.datastore.save({ + method: 'insert', + key: taskKey, + data: {}, + }); + + return this.datastore.get(taskKey); + } + + async testUpdate() { + // [START datastore_update] + const taskKey = datastore.key('Task'); + const task = { + category: 'Personal', + done: false, + priority: 4, + description: 'Learn Cloud Datastore', + }; + + const entity = { + key: taskKey, + data: task, + }; + + await datastore.update(entity); + // Task updated successfully. + // [END datastore_update] + + await this.datastore.save({ + method: 'insert', + key: taskKey, + data: {}, + }); + return this.datastore.update({key: taskKey, data: task}); + } + + async testDelete() { + // [START datastore_delete] + const taskKey = datastore.key('Task'); + await datastore.delete(taskKey); + // Task deleted successfully. + // [END datastore_delete] + await this.datastore.save({ + method: 'insert', + key: taskKey, + data: {}, + }); + return this.datastore.delete(taskKey); + } + + async testBatchUpsert() { + // [START datastore_batch_upsert] + const taskKey1 = this.datastore.key(['Task', 1]); + const taskKey2 = this.datastore.key(['Task', 2]); + + const task1 = { + category: 'Personal', + done: false, + priority: 4, + description: 'Learn Cloud Datastore', + }; + + const task2 = { + category: 'Work', + done: false, + priority: 8, + description: 'Integrate Cloud Datastore', + }; + + const entities = [ + { + key: taskKey1, + data: task1, + }, + { + key: taskKey2, + data: task2, + }, + ]; + + await datastore.upsert(entities); + // Tasks inserted successfully. + // [END datastore_batch_upsert] + + return this.datastore.upsert([ + { + key: taskKey1, + data: task1, + }, + { + key: taskKey2, + data: task2, + }, + ]); + } + + async testBatchLookup() { + // [START datastore_batch_lookup] + const taskKey1 = this.datastore.key(['Task', 1]); + const taskKey2 = this.datastore.key(['Task', 2]); + + const keys = [taskKey1, taskKey2]; + + const [tasks] = await datastore.get(keys); + // Tasks retrieved successfully. + console.log(tasks); + // [END datastore_batch_lookup] + + return this.datastore.get([taskKey1, taskKey2]); + } + + async testBatchDelete() { + // [START datastore_batch_delete] + const taskKey1 = this.datastore.key(['Task', 1]); + const taskKey2 = this.datastore.key(['Task', 2]); + + const keys = [taskKey1, taskKey2]; + + await datastore.delete(keys); + // Tasks deleted successfully. + // [END datastore_batch_delete] + + return this.datastore.delete([taskKey1, taskKey2]); + } +} + +class Index extends TestHelper { + testUnindexedPropertyQuery() { + const datastore = this.datastore; + + // [START datastore_unindexed_property_query] + const query = datastore + .createQuery('Task') + .filter(new PropertyFilter('description', '=', 'A task description.')); + // [END datastore_unindexed_property_query] + + return this.datastore.runQuery(query); + } + + async testExplodingProperties() { + const original = datastore.key; + datastore.key = this.datastore.key; + + // [START datastore_exploding_properties] + const task = { + method: 'insert', + key: datastore.key('Task'), + data: { + tags: ['fun', 'programming', 'learn'], + collaborators: ['alice', 'bob', 'charlie'], + created: new Date(), + }, + }; + // [END datastore_exploding_properties] + + datastore.key = original; + + await this.datastore.save(task); + assert.ok(task.key); + assert.ok(task.key.id); + } +} + +class Metadata extends TestHelper { + async testNamespaceRunQuery() { + const datastore = this.datastore; + + const startNamespace = 'Animals'; + const endNamespace = 'Zoos'; + + await datastore.save({ + key: datastore.key({ + namespace: 'Animals', + path: ['Ant', 1], + }), + data: {}, + }); + + // [START datastore_namespace_run_query] + async function runNamespaceQuery(startNamespace, endNamespace) { + const startKey = datastore.key(['__namespace__', startNamespace]); + const endKey = datastore.key(['__namespace__', endNamespace]); + + const query = datastore + .createQuery('__namespace__') + .select('__key__') + .filter( + and([ + new PropertyFilter('__key__', '>=', startKey), + new PropertyFilter('__key__', '<', endKey), + ]), + ); + + const [entities] = await datastore.runQuery(query); + const namespaces = entities.map(entity => entity[datastore.KEY].name); + + console.log('Namespaces:'); + namespaces.forEach(namespace => console.log(namespace)); + + return namespaces; + } + // [END datastore_namespace_run_query] + + const namespaces = await runNamespaceQuery(startNamespace, endNamespace); + assert.strictEqual(namespaces.includes('Animals'), true); + } + + async testKindRunQuery() { + const datastore = this.datastore; + + // [START datastore_kind_run_query] + async function runKindQuery() { + const query = datastore.createQuery('__kind__').select('__key__'); + + const [entities] = await datastore.runQuery(query); + const kinds = entities.map(entity => entity[datastore.KEY].name); + + console.log('Kinds:'); + kinds.forEach(kind => console.log(kind)); + + return kinds; + } + // [END datastore_kind_run_query] + const kinds = await runKindQuery(); + assert.strictEqual(kinds.includes('Account'), true); + } + + async testPropertyRunQuery() { + const datastore = this.datastore; + + // [START datastore_property_run_query] + async function runPropertyQuery() { + const query = datastore.createQuery('__property__').select('__key__'); + const [entities] = await datastore.runQuery(query); + // @TODO convert below object to map + const propertiesByKind = {}; + + entities.forEach(entity => { + const key = entity[datastore.KEY]; + const kind = key.path[1]; + const property = key.path[3]; + + propertiesByKind[kind] = propertiesByKind[kind] || []; + propertiesByKind[kind].push(property); + }); + + console.log('Properties by Kind:'); + for (const key in propertiesByKind) { + console.log(key, propertiesByKind[key]); + } + + return propertiesByKind; + } + // [END datastore_property_run_query] + const propertiesByKind = await runPropertyQuery(); + assert.deepStrictEqual(propertiesByKind.Account, ['balance']); + } + + async testPropertyByKindRunQuery() { + const datastore = this.datastore; + + // [START datastore_property_by_kind_run_query] + async function runPropertyByKindQuery() { + const ancestorKey = datastore.key(['__kind__', 'Account']); + + const query = datastore + .createQuery('__property__') + .hasAncestor(ancestorKey); + const [entities] = await datastore.runQuery(query); + + const representationsByProperty = {}; + + entities.forEach(entity => { + const key = entity[datastore.KEY]; + const propertyName = key.name; + const propertyType = entity.property_representation; + + representationsByProperty[propertyName] = propertyType; + }); + + console.log('Task property representations:'); + for (const key in representationsByProperty) { + console.log(key, representationsByProperty[key]); + } + + return representationsByProperty; + } + // [END datastore_property_by_kind_run_query] + + const propertiesByKind = await runPropertyByKindQuery(); + assert.deepStrictEqual(propertiesByKind, { + balance: ['INT64'], + }); + } +} + +class Query extends TestHelper { + constructor(projectId) { + super(projectId); + + this.basicQuery = this.getBasicQuery(); + this.projectionQuery = this.getProjectionQuery(); + this.ancestorQuery = this.getAncestorQuery(); + } + + getBasicQuery() { + const datastore = this.datastore; + + // [START datastore_basic_query] + const query = datastore + .createQuery('Task') + .filter( + and([ + new PropertyFilter('done', '=', false), + new PropertyFilter('priority', '>=', 4), + ]), + ) + .order('priority', { + descending: true, + }); + // [END datastore_basic_query] + + return query; + } + + getProjectionQuery() { + const datastore = this.datastore; + + // [START datastore_projection_query] + const query = datastore + .createQuery('Task') + .select(['priority', 'percent_complete']); + // [END datastore_projection_query] + + return query; + } + + getAncestorQuery() { + const datastore = this.datastore; + + // [START datastore_ancestor_query] + const ancestorKey = datastore.key(['TaskList', 'default']); + + const query = datastore.createQuery('Task').hasAncestor(ancestorKey); + // [END datastore_ancestor_query] + + return query; + } + + async testRunQuery() { + const query = this.basicQuery; + + // [START datastore_run_query] + const [tasks] = await datastore.runQuery(query); + console.log('Tasks:'); + tasks.forEach(task => console.log(task)); + // [END datastore_run_query] + + return this.datastore.runQuery(query); + } + + testPropertyFilter() { + const datastore = this.datastore; + + // [START datastore_property_filter] + const query = datastore + .createQuery('Task') + .filter(new PropertyFilter('done', '=', false)); + // [END datastore_property_filter] + + return this.datastore.runQuery(query); + } + + testCompositeFilter() { + const datastore = this.datastore; + + // [START datastore_composite_filter] + const query = datastore + .createQuery('Task') + .filter( + and([ + new PropertyFilter('done', '=', false), + new PropertyFilter('priority', '=', 4), + ]), + ); + // [END datastore_composite_filter] + + return this.datastore.runQuery(query); + } + + testKeyFilter() { + const datastore = this.datastore; + + // [START datastore_key_filter] + const query = datastore + .createQuery('Task') + .filter( + new PropertyFilter('__key__', '>', datastore.key(['Task', 'someTask'])), + ); + // [END datastore_key_filter] + + return this.datastore.runQuery(query); + } + + testAscendingSort() { + const datastore = this.datastore; + + // [START datastore_ascending_sort] + const query = datastore.createQuery('Task').order('created'); + // [END datastore_ascending_sort] + + return this.datastore.runQuery(query); + } + + testDescendingSort() { + const datastore = this.datastore; + + // [START datastore_descending_sort] + const query = datastore.createQuery('Task').order('created', { + descending: true, + }); + // [END datastore_descending_sort] + + return this.datastore.runQuery(query); + } + + testMultiSort() { + const datastore = this.datastore; + + // [START datastore_multi_sort] + const query = datastore + .createQuery('Task') + .order('priority', { + descending: true, + }) + .order('created'); + // [END datastore_multi_sort] + + return this.datastore.runQuery(query); + } + + testKindlessQuery() { + const datastore = this.datastore; + const lastSeenKey = this.datastore.key(['Task', Date.now()]); + + // [START datastore_kindless_query] + const query = datastore + .createQuery() + .filter(new PropertyFilter('__key__', '>', lastSeenKey)) + .limit(1); + // [END datastore_kindless_query] + + return this.datastore.runQuery(query); + } + + async testRunQueryProjection() { + const datastore = this.datastore; + const query = this.projectionQuery; + + // [START datastore_run_query_projection] + async function runProjectionQuery() { + const priorities = []; + const percentCompletes = []; + const [tasks] = await datastore.runQuery(query); + tasks.forEach(task => { + priorities.push(task.priority); + percentCompletes.push(task.percent_complete); + }); + + return { + priorities: priorities, + percentCompletes: percentCompletes, + }; + } + // [END datastore_run_query_projection] + + return await runProjectionQuery(); + } + + testKeysOnlyQuery() { + const datastore = this.datastore; + + // [START datastore_keys_only_query] + const query = datastore.createQuery().select('__key__').limit(1); + // [END datastore_keys_only_query] + + return this.datastore.runQuery(query); + } + + testDistinctOnQuery() { + const datastore = this.datastore; + + // [START datastore_distinct_on_query] + const query = datastore + .createQuery('Task') + .groupBy('category') + .order('category') + .order('priority'); + // [END datastore_distinct_on_query] + + return this.datastore.runQuery(query); + } + + testArrayValueInequalityRange() { + const datastore = this.datastore; + + // [START datastore_array_value_inequality_range] + const query = datastore + .createQuery('Task') + .filter( + and([ + new PropertyFilter('tag', '>', 'learn'), + new PropertyFilter('tag', '<', 'math'), + ]), + ); + // [END datastore_array_value_inequality_range] + + return this.datastore.runQuery(query); + } + + testArrayValueEquality() { + const datastore = this.datastore; + + // [START datastore_array_value_equality] + const query = datastore + .createQuery('Task') + .filter( + and([ + new PropertyFilter('tag', '=', 'fun'), + new PropertyFilter('tag', '=', 'programming'), + ]), + ); + // [END datastore_array_value_equality] + + return this.datastore.runQuery(query); + } + + testInequalityRange() { + const datastore = this.datastore; + + // [START datastore_inequality_range] + const query = datastore + .createQuery('Task') + .filter( + and([ + new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), + new PropertyFilter('created', '<', new Date('2000-12-31T23:59:59z')), + ]), + ); + // [END datastore_inequality_range] + + return this.datastore.runQuery(query); + } + + testInequalityInvalid() { + const datastore = this.datastore; + + // [START datastore_inequality_invalid] + const query = datastore + .createQuery('Task') + .filter( + and([ + new PropertyFilter('priority', '>', 3), + new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), + ]), + ); + // [END datastore_inequality_invalid] + + return this.datastore.runQuery(query); + } + + testEqualAndInequalityRange() { + const datastore = this.datastore; + + // [START datastore_equal_and_inequality_range] + const query = datastore + .createQuery('Task') + .filter( + and([ + new PropertyFilter('priority', '=', 4), + new PropertyFilter('done', '=', false), + new PropertyFilter('created', '>', new Date('1990-01-01T00:00:00z')), + new PropertyFilter('created', '<', new Date('2000-12-31T23:59:59z')), + ]), + ); + // [END datastore_equal_and_inequality_range] + + return this.datastore.runQuery(query); + } + + testInequalitySort() { + const datastore = this.datastore; + + // [START datastore_inequality_sort] + const query = datastore + .createQuery('Task') + .filter(new PropertyFilter('priority', '>', 3)) + .order('priority') + .order('created'); + // [END datastore_inequality_sort] + + return this.datastore.runQuery(query); + } + + testInequalitySortInvalidNotSame() { + const datastore = this.datastore; + + // [START datastore_inequality_sort_invalid_not_same] + const query = datastore + .createQuery('Task') + .filter(new PropertyFilter('priority', '>', 3)) + .order('created'); + // [END datastore_inequality_sort_invalid_not_same] + + return this.datastore.runQuery(query); + } + + testInequalitySortInvalidNotFirst() { + const datastore = this.datastore; + + // [START datastore_inequality_sort_invalid_not_first] + const query = datastore + .createQuery('Task') + .filter(new PropertyFilter('priority', '>', 3)) + .order('created') + .order('priority'); + // [END datastore_inequality_sort_invalid_not_first] + + return this.datastore.runQuery(query); + } + + testLimit() { + const datastore = this.datastore; + + // [START datastore_limit] + const query = datastore.createQuery('Task').limit(5); + // [END datastore_limit] + + return this.datastore.runQuery(query); + } + + async testCursorPaging() { + const datastore = this.datastore; + const pageSize = 1; + + // [START datastore_cursor_paging] + // By default, google-cloud-node will automatically paginate through all of + // the results that match a query. However, this sample implements manual + // pagination using limits and cursor tokens. + async function runPageQuery(pageCursor) { + let query = datastore.createQuery('Task').limit(pageSize); + + if (pageCursor) { + query = query.start(pageCursor); + } + const results = await datastore.runQuery(query); + const entities = results[0]; + const info = results[1]; + + if (info.moreResults !== Datastore.NO_MORE_RESULTS) { + // If there are more results to retrieve, the end cursor is + // automatically set on `info`. To get this value directly, access + // the `endCursor` property. + const results = await runPageQuery(info.endCursor); + + // Concatenate entities + results[0] = entities.concat(results[0]); + return results; + } + + return [entities, info]; + } + // [END datastore_cursor_paging] + const [entities, info] = await runPageQuery(); + assert.strictEqual(Array.isArray(entities), true); + if (!info || !info.endCursor) { + throw new Error('An `info` with an `endCursor` is not present.'); + } + } + + async testEventualConsistentQuery() { + const datastoreMock = datastore; + datastore = this.datastore; + // [START datastore_eventual_consistent_query] + const ancestorKey = datastore.key(['TaskList', 'default']); + const query = datastore.createQuery('Task').hasAncestor(ancestorKey); + + query.run({consistency: 'eventual'}); + // [END datastore_eventual_consistent_query] + const [entities] = await query.run({consistency: 'eventual'}); + datastore = datastoreMock; + return entities; + } +} + +// [START datastore_transactional_update] +async function transferFunds(fromKey, toKey, amount) { + const transaction = datastore.transaction(); + await transaction.run(); + const results = await Promise.all([ + transaction.get(fromKey), + transaction.get(toKey), + ]); + const accounts = results.map(result => result[0]); + + accounts[0].balance -= amount; + accounts[1].balance += amount; + + transaction.save([ + { + key: fromKey, + data: accounts[0], + }, + { + key: toKey, + data: accounts[1], + }, + ]); + + return await transaction.commit(); +} +// [END datastore_transactional_update] + +class Transaction extends TestHelper { + constructor(projectId) { + super(projectId); + this.fromKey = this.datastore.key(['Bank', 1, 'Account', 1]); + this.toKey = this.datastore.key(['Bank', 1, 'Account', 2]); + + this.originalBalance = 100; + this.amountToTransfer = 10; + } + + restoreBankAccountBalances(config) { + const entities = config.keys.map(key => { + return { + key: key, + data: { + balance: config.balance, + }, + }; + }); + + return this.datastore.save(entities); + } + + async testTransactionalUpdate() { + const fromKey = this.fromKey; + const toKey = this.toKey; + const originalBalance = this.originalBalance; + const amountToTransfer = this.amountToTransfer; + const datastoreMock = datastore; + + // Overwrite so the real Datastore instance is used in `transferFunds`. + datastore = this.datastore; + try { + await this.restoreBankAccountBalances({ + keys: [fromKey, toKey], + balance: originalBalance, + }); + await transferFunds(fromKey, toKey, amountToTransfer); + const results = await Promise.all([ + this.datastore.get(fromKey), + this.datastore.get(toKey), + ]); + const accounts = results.map(result => result[0]); + // Restore `datastore` to the mock API. + datastore = datastoreMock; + assert.strictEqual( + accounts[0].balance, + originalBalance - amountToTransfer, + ); + assert.strictEqual( + accounts[1].balance, + originalBalance + amountToTransfer, + ); + } catch (err) { + datastore = datastoreMock; + throw err; + } + } + + async testTransactionalRetry() { + // Overwrite so the real Datastore instance is used in `transferFunds`. + const datastoreMock = datastore; + datastore = this.datastore; + + const fromKey = this.fromKey; + const toKey = this.toKey; + await this.restoreBankAccountBalances({ + keys: [fromKey, toKey], + balance: this.originalBalance, + }); + + // [START datastore_transactional_retry] + async function transferFundsWithRetry() { + const maxTries = 5; + + async function tryRequest(currentAttempt, delay) { + try { + await transferFunds(fromKey, toKey, 10); + } catch (err) { + if (currentAttempt <= maxTries) { + // Use exponential backoff + setTimeout(async () => { + await tryRequest(currentAttempt + 1, delay * 2); + }, delay); + } + throw err; + } + } + + await tryRequest(1, 100); + } + // [END datastore_transactional_retry] + await transferFundsWithRetry(); + // Restore `datastore` to the mock API. + datastore = datastoreMock; + } + + async testTransactionalGetOrCreate() { + const taskKey = this.datastore.key(['Task', Date.now()]); + + // Overwrite so the real Datastore instance is used in `transferFunds`. + const datastoreMock = datastore; + datastore = this.datastore; + + // [START datastore_transactional_get_or_create] + async function getOrCreate(taskKey, taskData) { + const taskEntity = { + key: taskKey, + data: taskData, + }; + const transaction = datastore.transaction(); + + try { + await transaction.run(); + const [task] = await transaction.get(taskKey); + if (task) { + // The task entity already exists. + await transaction.rollback(); + } else { + // Create the task entity. + transaction.save(taskEntity); + await transaction.commit(); + } + return taskEntity; + } catch (err) { + await transaction.rollback(); + } + } + // [END datastore_transactional_get_or_create] + try { + let task = await getOrCreate(taskKey, {}); + assert.ok(task, 'Should have a task.'); + task = await getOrCreate(taskKey, {}); + assert.ok(task, 'Should have a task.'); + // Restore `datastore` to the mock API. + datastore = datastoreMock; + } catch (err) { + // Restore `datastore` to the mock API. + datastore = datastoreMock; + throw err; + } + } + + async testSingleEntityGroupReadOnly() { + // Overwrite so the real Datastore instance is used in `transferFunds`. + const datastoreMock = datastore; + datastore = this.datastore; + + // [START datastore_transactional_single_entity_group_read_only] + async function getTaskListEntities() { + const transaction = datastore.transaction({readOnly: true}); + try { + const taskListKey = datastore.key(['TaskList', 'default']); + + await transaction.run(); + const [taskList] = await transaction.get(taskListKey); + const query = datastore.createQuery('Task').hasAncestor(taskListKey); + const [taskListEntities] = await transaction.runQuery(query); + await transaction.commit(); + return [taskList, taskListEntities]; + } catch (err) { + await transaction.rollback(); + } + } + // [END datastore_transactional_single_entity_group_read_only] + + return getTaskListEntities().then( + results => { + // Restore `datastore` to the mock API. + datastore = datastoreMock; + assert.strictEqual(results.length, 2); + assert.strictEqual(Array.isArray(results[1]), true); + }, + err => { + // Restore `datastore` to the mock API. + datastore = datastoreMock; + return Promise.reject(err); + }, + ); + } +} + +module.exports = { + Entity: Entity, + Index: Index, + Metadata: Metadata, + Query: Query, + Transaction: Transaction, +}; diff --git a/handwritten/nodejs-datastore/samples/error.js b/handwritten/nodejs-datastore/samples/error.js new file mode 100644 index 00000000000..96445dbb67f --- /dev/null +++ b/handwritten/nodejs-datastore/samples/error.js @@ -0,0 +1,50 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +// sample-metadata +// title: error sample +// description: sample show how to handle and process error +// usage: node error.js + +const {Datastore} = require('@google-cloud/datastore'); + +// [START error] +function main() { + // Creates a client + const datastore = new Datastore(); + + const query = datastore.createQuery(['Company']).start('badrequest'); + + async function runQuery() { + try { + const [result] = await datastore.runQuery(query); + // etc., etc. + return result; + } catch (error) { + // do something with error. + console.log(error.code); // 3 + //Forward the error to caller + throw error; + } + } + + runQuery().catch(err => { + console.log(err.message); // "Error parsing protocol message" + }); + // [END error] +} + +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/export.js b/handwritten/nodejs-datastore/samples/export.js new file mode 100644 index 00000000000..234a748d9cd --- /dev/null +++ b/handwritten/nodejs-datastore/samples/export.js @@ -0,0 +1,48 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +async function main(bucket = 'YOUR_BUCKET_NAME') { + // [START datastore_admin_entities_export] + const {Datastore} = require('@google-cloud/datastore'); + const datastore = new Datastore(); + + async function exportEntities() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const bucket = 'YOUR_BUCKET_NAME'; + + const [exportOperation] = await datastore.export({bucket}); + await exportOperation.promise(); + + // The export operation has created a new file in your bucket, e.g. + // gs://{YOUR_BUCKET_NAME}/{timestamp}/{timestamp}.overall_export.metadata + console.log(`Export file created: ${exportOperation.result.outputUrl}`); + + // You may also choose to include only specific kinds and namespaces. + const [specificExportOperation] = await datastore.export({ + bucket, + kinds: ['Employee', 'Task'], + namespaces: ['Company'], + }); + await specificExportOperation.promise(); + console.log(specificExportOperation.result.outputUrl); + } + + exportEntities(); + // [END datastore_admin_entities_export] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.allocate_ids.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.allocate_ids.js new file mode 100644 index 00000000000..e47fb3a8067 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.allocate_ids.js @@ -0,0 +1,73 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, keys) { + // [START datastore_v1_generated_Datastore_AllocateIds_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * Required. A list of keys with incomplete key paths for which to allocate + * IDs. No key may be reserved/read-only. + */ + // const keys = [1,2,3,4] + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callAllocateIds() { + // Construct request + const request = { + projectId, + keys, + }; + + // Run request + const response = await datastoreClient.allocateIds(request); + console.log(response); + } + + callAllocateIds(); + // [END datastore_v1_generated_Datastore_AllocateIds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.begin_transaction.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.begin_transaction.js new file mode 100644 index 00000000000..048d1ef5e3a --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.begin_transaction.js @@ -0,0 +1,71 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId) { + // [START datastore_v1_generated_Datastore_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * Options for a new transaction. + */ + // const transactionOptions = {} + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callBeginTransaction() { + // Construct request + const request = { + projectId, + }; + + // Run request + const response = await datastoreClient.beginTransaction(request); + console.log(response); + } + + callBeginTransaction(); + // [END datastore_v1_generated_Datastore_BeginTransaction_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.commit.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.commit.js new file mode 100644 index 00000000000..6adbb99605f --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.commit.js @@ -0,0 +1,97 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId) { + // [START datastore_v1_generated_Datastore_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * The type of commit to perform. Defaults to `TRANSACTIONAL`. + */ + // const mode = {} + /** + * The identifier of the transaction associated with the commit. A + * transaction identifier is returned by a call to + * Datastore.BeginTransaction google.datastore.v1.Datastore.BeginTransaction. + */ + // const transaction = Buffer.from('string') + /** + * Options for beginning a new transaction for this request. + * The transaction is committed when the request completes. If specified, + * TransactionOptions.mode google.datastore.v1.TransactionOptions must be + * TransactionOptions.ReadWrite google.datastore.v1.TransactionOptions.ReadWrite. + */ + // const singleUseTransaction = {} + /** + * The mutations to perform. + * When mode is `TRANSACTIONAL`, mutations affecting a single entity are + * applied in order. The following sequences of mutations affecting a single + * entity are not permitted in a single `Commit` request: + * - `insert` followed by `insert` + * - `update` followed by `insert` + * - `upsert` followed by `insert` + * - `delete` followed by `update` + * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single + * entity. + */ + // const mutations = [1,2,3,4] + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callCommit() { + // Construct request + const request = { + projectId, + }; + + // Run request + const response = await datastoreClient.commit(request); + console.log(response); + } + + callCommit(); + // [END datastore_v1_generated_Datastore_Commit_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.lookup.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.lookup.js new file mode 100644 index 00000000000..10605896735 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.lookup.js @@ -0,0 +1,83 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, keys) { + // [START datastore_v1_generated_Datastore_Lookup_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * The options for this lookup request. + */ + // const readOptions = {} + /** + * Required. Keys of entities to look up. + */ + // const keys = [1,2,3,4] + /** + * The properties to return. Defaults to returning all properties. + * If this field is set and an entity has a property not referenced in the + * mask, it will be absent from LookupResponse.found.entity.properties . + * The entity's key is always returned. + */ + // const propertyMask = {} + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callLookup() { + // Construct request + const request = { + projectId, + keys, + }; + + // Run request + const response = await datastoreClient.lookup(request); + console.log(response); + } + + callLookup(); + // [END datastore_v1_generated_Datastore_Lookup_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.reserve_ids.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.reserve_ids.js new file mode 100644 index 00000000000..d6a5b855964 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.reserve_ids.js @@ -0,0 +1,73 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, keys) { + // [START datastore_v1_generated_Datastore_ReserveIds_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * Required. A list of keys with complete key paths whose numeric IDs should + * not be auto-allocated. + */ + // const keys = [1,2,3,4] + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callReserveIds() { + // Construct request + const request = { + projectId, + keys, + }; + + // Run request + const response = await datastoreClient.reserveIds(request); + console.log(response); + } + + callReserveIds(); + // [END datastore_v1_generated_Datastore_ReserveIds_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.rollback.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.rollback.js new file mode 100644 index 00000000000..27757dcc828 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.rollback.js @@ -0,0 +1,73 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, transaction) { + // [START datastore_v1_generated_Datastore_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * Required. The transaction identifier, returned by a call to + * Datastore.BeginTransaction google.datastore.v1.Datastore.BeginTransaction. + */ + // const transaction = Buffer.from('string') + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callRollback() { + // Construct request + const request = { + projectId, + transaction, + }; + + // Run request + const response = await datastoreClient.rollback(request); + console.log(response); + } + + callRollback(); + // [END datastore_v1_generated_Datastore_Rollback_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.run_aggregation_query.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.run_aggregation_query.js new file mode 100644 index 00000000000..b5c44b6ef74 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.run_aggregation_query.js @@ -0,0 +1,91 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId) { + // [START datastore_v1_generated_Datastore_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * Entities are partitioned into subsets, identified by a partition ID. + * Queries are scoped to a single partition. + * This partition ID is normalized with the standard default context + * partition ID. + */ + // const partitionId = {} + /** + * The options for this query. + */ + // const readOptions = {} + /** + * The query to run. + */ + // const aggregationQuery = {} + /** + * The GQL query to run. This query must be an aggregation query. + */ + // const gqlQuery = {} + /** + * Optional. Explain options for the query. If set, additional query + * statistics will be returned. If not, only query results will be returned. + */ + // const explainOptions = {} + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callRunAggregationQuery() { + // Construct request + const request = { + projectId, + }; + + // Run request + const response = await datastoreClient.runAggregationQuery(request); + console.log(response); + } + + callRunAggregationQuery(); + // [END datastore_v1_generated_Datastore_RunAggregationQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore.run_query.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore.run_query.js new file mode 100644 index 00000000000..70237069d9c --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore.run_query.js @@ -0,0 +1,98 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId) { + // [START datastore_v1_generated_Datastore_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 ID of the project against which to make the request. + */ + // const projectId = 'abc123' + /** + * The ID of the database against which to make the request. + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + */ + // const databaseId = 'abc123' + /** + * Entities are partitioned into subsets, identified by a partition ID. + * Queries are scoped to a single partition. + * This partition ID is normalized with the standard default context + * partition ID. + */ + // const partitionId = {} + /** + * The options for this query. + */ + // const readOptions = {} + /** + * The query to run. + */ + // const query = {} + /** + * The GQL query to run. This query must be a non-aggregation query. + */ + // const gqlQuery = {} + /** + * The properties to return. + * This field must not be set for a projection query. + * See + * LookupRequest.property_mask google.datastore.v1.LookupRequest.property_mask. + */ + // const propertyMask = {} + /** + * Optional. Explain options for the query. If set, additional query + * statistics will be returned. If not, only query results will be returned. + */ + // const explainOptions = {} + + // Imports the Datastore library + const {DatastoreClient} = require('@google-cloud/datastore').v1; + + // Instantiates a client + const datastoreClient = new DatastoreClient(); + + async function callRunQuery() { + // Construct request + const request = { + projectId, + }; + + // Run request + const response = await datastoreClient.runQuery(request); + console.log(response); + } + + callRunQuery(); + // [END datastore_v1_generated_Datastore_RunQuery_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.create_index.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.create_index.js new file mode 100644 index 00000000000..a54d726a8a7 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.create_index.js @@ -0,0 +1,66 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_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. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * The index to create. The name and state fields are output only and will be + * ignored. Single property indexes cannot be created or deleted. + */ + // const index = {} + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callCreateIndex() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await adminClient.createIndex(request); + const [response] = await operation.promise(); + console.log(response); + } + + callCreateIndex(); + // [END datastore_v1_generated_DatastoreAdmin_CreateIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.delete_index.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.delete_index.js new file mode 100644 index 00000000000..8b74e8d5e4d --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.delete_index.js @@ -0,0 +1,65 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_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. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * The resource ID of the index to delete. + */ + // const indexId = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callDeleteIndex() { + // Construct request + const request = { + }; + + // Run request + const [operation] = await adminClient.deleteIndex(request); + const [response] = await operation.promise(); + console.log(response); + } + + callDeleteIndex(); + // [END datastore_v1_generated_DatastoreAdmin_DeleteIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.export_entities.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.export_entities.js new file mode 100644 index 00000000000..de3f899694b --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.export_entities.js @@ -0,0 +1,89 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, outputUrlPrefix) { + // [START datastore_v1_generated_DatastoreAdmin_ExportEntities_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. Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * Client-assigned labels. + */ + // const labels = [1,2,3,4] + /** + * Description of what data from the project is included in the export. + */ + // const entityFilter = {} + /** + * Required. Location for the export metadata and data files. + * The full resource URL of the external storage location. Currently, only + * Google Cloud Storage is supported. So output_url_prefix should be of the + * form: `gs://BUCKET_NAME/NAMESPACE_PATH`, where `BUCKET_NAME` is the + * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud + * Storage namespace path (this is not a Cloud Datastore namespace). For more + * information about Cloud Storage namespace paths, see + * Object name + * considerations (https://cloud.google.com/storage/docs/naming#object-considerations). + * The resulting files will be nested deeper than the specified URL prefix. + * The final output URL will be provided in the + * google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url + * field. That value should be used for subsequent ImportEntities operations. + * By nesting the data files deeper, the same Cloud Storage bucket can be used + * in multiple ExportEntities operations without conflict. + */ + // const outputUrlPrefix = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callExportEntities() { + // Construct request + const request = { + projectId, + outputUrlPrefix, + }; + + // Run request + const [operation] = await adminClient.exportEntities(request); + const [response] = await operation.promise(); + console.log(response); + } + + callExportEntities(); + // [END datastore_v1_generated_DatastoreAdmin_ExportEntities_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.get_index.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.get_index.js new file mode 100644 index 00000000000..9c930af60b8 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.get_index.js @@ -0,0 +1,64 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_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. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * The resource ID of the index to get. + */ + // const indexId = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callGetIndex() { + // Construct request + const request = { + }; + + // Run request + const response = await adminClient.getIndex(request); + console.log(response); + } + + callGetIndex(); + // [END datastore_v1_generated_DatastoreAdmin_GetIndex_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.import_entities.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.import_entities.js new file mode 100644 index 00000000000..a17a03e9c2f --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.import_entities.js @@ -0,0 +1,90 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(projectId, inputUrl) { + // [START datastore_v1_generated_DatastoreAdmin_ImportEntities_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. Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + * Client-assigned labels. + */ + // const labels = [1,2,3,4] + /** + * Required. The full resource URL of the external storage location. + * Currently, only Google Cloud Storage is supported. So input_url should be + * of the form: + * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where + * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is + * an optional Cloud Storage namespace path (this is not a Cloud Datastore + * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written + * by the ExportEntities operation. For more information about Cloud Storage + * namespace paths, see + * Object name + * considerations (https://cloud.google.com/storage/docs/naming#object-considerations). + * For more information, see + * google.datastore.admin.v1.ExportEntitiesResponse.output_url google.datastore.admin.v1.ExportEntitiesResponse.output_url. + */ + // const inputUrl = 'abc123' + /** + * Optionally specify which kinds/namespaces are to be imported. If provided, + * the list must be a subset of the EntityFilter used in creating the export, + * otherwise a FAILED_PRECONDITION error will be returned. If no filter is + * specified then all entities from the export are imported. + */ + // const entityFilter = {} + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callImportEntities() { + // Construct request + const request = { + projectId, + inputUrl, + }; + + // Run request + const [operation] = await adminClient.importEntities(request); + const [response] = await operation.promise(); + console.log(response); + } + + callImportEntities(); + // [END datastore_v1_generated_DatastoreAdmin_ImportEntities_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.list_indexes.js b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.list_indexes.js new file mode 100644 index 00000000000..624f6423148 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/datastore_admin.list_indexes.js @@ -0,0 +1,74 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main() { + // [START datastore_v1_generated_DatastoreAdmin_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. + */ + /** + * Project ID against which to make the request. + */ + // const projectId = 'abc123' + /** + */ + // const filter = 'abc123' + /** + * The maximum number of items to return. If zero, then all results will be + * returned. + */ + // const pageSize = 1234 + /** + * The next_page_token value returned from a previous List request, if any. + */ + // const pageToken = 'abc123' + + // Imports the Admin library + const {DatastoreAdminClient} = require('@google-cloud/datastore-admin').v1; + + // Instantiates a client + const adminClient = new DatastoreAdminClient(); + + async function callListIndexes() { + // Construct request + const request = { + }; + + // Run request + const iterable = adminClient.listIndexesAsync(request); + for await (const response of iterable) { + console.log(response); + } + } + + callListIndexes(); + // [END datastore_v1_generated_DatastoreAdmin_ListIndexes_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json new file mode 100644 index 00000000000..41431b0f77a --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata.google.datastore.admin.v1.json @@ -0,0 +1,303 @@ +{ + "clientLibrary": { + "name": "nodejs-admin", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.datastore.admin.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ExportEntities_async", + "title": "DatastoreAdmin exportEntities Sample", + "origin": "API_DEFINITION", + "description": " Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities 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.", + "canonical": true, + "file": "datastore_admin.export_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "entity_filter", + "type": ".google.datastore.admin.v1.EntityFilter" + }, + { + "name": "output_url_prefix", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ExportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ImportEntities_async", + "title": "DatastoreAdmin importEntities Sample", + "origin": "API_DEFINITION", + "description": " Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.", + "canonical": true, + "file": "datastore_admin.import_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "input_url", + "type": "TYPE_STRING" + }, + { + "name": "entity_filter", + "type": ".google.datastore.admin.v1.EntityFilter" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ImportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_CreateIndex_async", + "title": "DatastoreAdmin createIndex Sample", + "origin": "API_DEFINITION", + "description": " Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. During index creation, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. Indexes with a single property cannot be created.", + "canonical": true, + "file": "datastore_admin.create_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index", + "type": ".google.datastore.admin.v1.Index" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "CreateIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_DeleteIndex_async", + "title": "DatastoreAdmin deleteIndex Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. On successful execution of the request, the index will be in a `DELETING` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. During index deletion, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.", + "canonical": true, + "file": "datastore_admin.delete_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "DeleteIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_GetIndex_async", + "title": "DatastoreAdmin getIndex Sample", + "origin": "API_DEFINITION", + "description": " Gets an index.", + "canonical": true, + "file": "datastore_admin.get_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.datastore.admin.v1.Index", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "GetIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ListIndexes_async", + "title": "DatastoreAdmin listIndexes Sample", + "origin": "API_DEFINITION", + "description": " Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.", + "canonical": true, + "file": "datastore_admin.list_indexes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListIndexes", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.datastore.admin.v1.ListIndexesResponse", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ListIndexes", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + } + ] +} diff --git a/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata.google.datastore.v1.json b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata.google.datastore.v1.json new file mode 100644 index 00000000000..27ec516fcc5 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata.google.datastore.v1.json @@ -0,0 +1,439 @@ +{ + "clientLibrary": { + "name": "nodejs-datastore", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.datastore.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "datastore_v1_generated_Datastore_Lookup_async", + "title": "datastore lookup Sample", + "origin": "API_DEFINITION", + "description": " Looks up entities by key.", + "canonical": true, + "file": "datastore.lookup.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 68, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Lookup", + "fullName": "google.datastore.v1.Datastore.Lookup", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.LookupResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Lookup", + "fullName": "google.datastore.v1.Datastore.Lookup", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_RunQuery_async", + "title": "datastore runQuery Sample", + "origin": "API_DEFINITION", + "description": " Queries for entities.", + "canonical": true, + "file": "datastore.run_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunQuery", + "fullName": "google.datastore.v1.Datastore.RunQuery", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "partition_id", + "type": ".google.datastore.v1.PartitionId" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "query", + "type": ".google.datastore.v1.Query" + }, + { + "name": "gql_query", + "type": ".google.datastore.v1.GqlQuery" + } + ], + "resultType": ".google.datastore.v1.RunQueryResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "RunQuery", + "fullName": "google.datastore.v1.Datastore.RunQuery", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_RunAggregationQuery_async", + "title": "datastore runAggregationQuery Sample", + "origin": "API_DEFINITION", + "description": " Runs an aggregation query.", + "canonical": true, + "file": "datastore.run_aggregation_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 78, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunAggregationQuery", + "fullName": "google.datastore.v1.Datastore.RunAggregationQuery", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "partition_id", + "type": ".google.datastore.v1.PartitionId" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "aggregation_query", + "type": ".google.datastore.v1.AggregationQuery" + }, + { + "name": "gql_query", + "type": ".google.datastore.v1.GqlQuery" + } + ], + "resultType": ".google.datastore.v1.RunAggregationQueryResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "RunAggregationQuery", + "fullName": "google.datastore.v1.Datastore.RunAggregationQuery", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_BeginTransaction_async", + "title": "datastore beginTransaction Sample", + "origin": "API_DEFINITION", + "description": " Begins a new transaction.", + "canonical": true, + "file": "datastore.begin_transaction.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BeginTransaction", + "fullName": "google.datastore.v1.Datastore.BeginTransaction", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "transaction_options", + "type": ".google.datastore.v1.TransactionOptions" + } + ], + "resultType": ".google.datastore.v1.BeginTransactionResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "BeginTransaction", + "fullName": "google.datastore.v1.Datastore.BeginTransaction", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_Commit_async", + "title": "datastore commit Sample", + "origin": "API_DEFINITION", + "description": " Commits a transaction, optionally creating, deleting or modifying some entities.", + "canonical": true, + "file": "datastore.commit.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 89, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Commit", + "fullName": "google.datastore.v1.Datastore.Commit", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "mode", + "type": ".google.datastore.v1.CommitRequest.Mode" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "single_use_transaction", + "type": ".google.datastore.v1.TransactionOptions" + }, + { + "name": "mutations", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.CommitResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Commit", + "fullName": "google.datastore.v1.Datastore.Commit", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_Rollback_async", + "title": "datastore rollback Sample", + "origin": "API_DEFINITION", + "description": " Rolls back a transaction.", + "canonical": true, + "file": "datastore.rollback.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Rollback", + "fullName": "google.datastore.v1.Datastore.Rollback", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.datastore.v1.RollbackResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Rollback", + "fullName": "google.datastore.v1.Datastore.Rollback", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_AllocateIds_async", + "title": "datastore allocateIds Sample", + "origin": "API_DEFINITION", + "description": " Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.", + "canonical": true, + "file": "datastore.allocate_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AllocateIds", + "fullName": "google.datastore.v1.Datastore.AllocateIds", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.AllocateIdsResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "AllocateIds", + "fullName": "google.datastore.v1.Datastore.AllocateIds", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_ReserveIds_async", + "title": "datastore reserveIds Sample", + "origin": "API_DEFINITION", + "description": " Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.", + "canonical": true, + "file": "datastore.reserve_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReserveIds", + "fullName": "google.datastore.v1.Datastore.ReserveIds", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.ReserveIdsResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "ReserveIds", + "fullName": "google.datastore.v1.Datastore.ReserveIds", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + } + ] +} diff --git a/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata_google.datastore.admin.v1.json b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata_google.datastore.admin.v1.json new file mode 100644 index 00000000000..a96b7eab4d2 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata_google.datastore.admin.v1.json @@ -0,0 +1,303 @@ +{ + "clientLibrary": { + "name": "nodejs-admin", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.datastore.admin.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ExportEntities_async", + "title": "DatastoreAdmin exportEntities Sample", + "origin": "API_DEFINITION", + "description": " Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities 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.", + "canonical": true, + "file": "datastore_admin.export_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 81, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ExportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "entity_filter", + "type": ".google.datastore.admin.v1.EntityFilter" + }, + { + "name": "output_url_prefix", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ExportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ExportEntities", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ImportEntities_async", + "title": "DatastoreAdmin importEntities Sample", + "origin": "API_DEFINITION", + "description": " Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.", + "canonical": true, + "file": "datastore_admin.import_entities.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 82, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ImportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "labels", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "input_url", + "type": "TYPE_STRING" + }, + { + "name": "entity_filter", + "type": ".google.datastore.admin.v1.EntityFilter" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ImportEntities", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ImportEntities", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_CreateIndex_async", + "title": "DatastoreAdmin createIndex Sample", + "origin": "API_DEFINITION", + "description": " Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. During index creation, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. Indexes with a single property cannot be created.", + "canonical": true, + "file": "datastore_admin.create_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index", + "type": ".google.datastore.admin.v1.Index" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "CreateIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.CreateIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_DeleteIndex_async", + "title": "DatastoreAdmin deleteIndex Sample", + "origin": "API_DEFINITION", + "description": " Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. On successful execution of the request, the index will be in a `DELETING` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. During index deletion, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.", + "canonical": true, + "file": "datastore_admin.delete_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 57, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "DeleteIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.longrunning.Operation", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "DeleteIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.DeleteIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_GetIndex_async", + "title": "DatastoreAdmin getIndex Sample", + "origin": "API_DEFINITION", + "description": " Gets an index.", + "canonical": true, + "file": "datastore_admin.get_index.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 56, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "GetIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "index_id", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.datastore.admin.v1.Index", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "GetIndex", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.GetIndex", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_DatastoreAdmin_ListIndexes_async", + "title": "DatastoreAdmin listIndexes Sample", + "origin": "API_DEFINITION", + "description": " Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.", + "canonical": true, + "file": "datastore_admin.list_indexes.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 66, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ListIndexes", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "filter", + "type": "TYPE_STRING" + }, + { + "name": "page_size", + "type": "TYPE_INT32" + }, + { + "name": "page_token", + "type": "TYPE_STRING" + } + ], + "resultType": ".google.datastore.admin.v1.ListIndexesResponse", + "client": { + "shortName": "DatastoreAdminClient", + "fullName": "google.datastore.admin.v1.DatastoreAdminClient" + }, + "method": { + "shortName": "ListIndexes", + "fullName": "google.datastore.admin.v1.DatastoreAdmin.ListIndexes", + "service": { + "shortName": "DatastoreAdmin", + "fullName": "google.datastore.admin.v1.DatastoreAdmin" + } + } + } + } + ] +} diff --git a/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata_google.datastore.v1.json b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata_google.datastore.v1.json new file mode 100644 index 00000000000..ea85b6beb2c --- /dev/null +++ b/handwritten/nodejs-datastore/samples/generated/v1/snippet_metadata_google.datastore.v1.json @@ -0,0 +1,455 @@ +{ + "clientLibrary": { + "name": "nodejs-datastore", + "version": "0.1.0", + "language": "TYPESCRIPT", + "apis": [ + { + "id": "google.datastore.v1", + "version": "v1" + } + ] + }, + "snippets": [ + { + "regionTag": "datastore_v1_generated_Datastore_Lookup_async", + "title": "datastore lookup Sample", + "origin": "API_DEFINITION", + "description": " Looks up entities by key.", + "canonical": true, + "file": "datastore.lookup.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 75, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Lookup", + "fullName": "google.datastore.v1.Datastore.Lookup", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + }, + { + "name": "property_mask", + "type": ".google.datastore.v1.PropertyMask" + } + ], + "resultType": ".google.datastore.v1.LookupResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Lookup", + "fullName": "google.datastore.v1.Datastore.Lookup", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_RunQuery_async", + "title": "datastore runQuery Sample", + "origin": "API_DEFINITION", + "description": " Queries for entities.", + "canonical": true, + "file": "datastore.run_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 90, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunQuery", + "fullName": "google.datastore.v1.Datastore.RunQuery", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "partition_id", + "type": ".google.datastore.v1.PartitionId" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "query", + "type": ".google.datastore.v1.Query" + }, + { + "name": "gql_query", + "type": ".google.datastore.v1.GqlQuery" + }, + { + "name": "property_mask", + "type": ".google.datastore.v1.PropertyMask" + }, + { + "name": "explain_options", + "type": ".google.datastore.v1.ExplainOptions" + } + ], + "resultType": ".google.datastore.v1.RunQueryResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "RunQuery", + "fullName": "google.datastore.v1.Datastore.RunQuery", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_RunAggregationQuery_async", + "title": "datastore runAggregationQuery Sample", + "origin": "API_DEFINITION", + "description": " Runs an aggregation query.", + "canonical": true, + "file": "datastore.run_aggregation_query.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 83, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "RunAggregationQuery", + "fullName": "google.datastore.v1.Datastore.RunAggregationQuery", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "partition_id", + "type": ".google.datastore.v1.PartitionId" + }, + { + "name": "read_options", + "type": ".google.datastore.v1.ReadOptions" + }, + { + "name": "aggregation_query", + "type": ".google.datastore.v1.AggregationQuery" + }, + { + "name": "gql_query", + "type": ".google.datastore.v1.GqlQuery" + }, + { + "name": "explain_options", + "type": ".google.datastore.v1.ExplainOptions" + } + ], + "resultType": ".google.datastore.v1.RunAggregationQueryResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "RunAggregationQuery", + "fullName": "google.datastore.v1.Datastore.RunAggregationQuery", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_BeginTransaction_async", + "title": "datastore beginTransaction Sample", + "origin": "API_DEFINITION", + "description": " Begins a new transaction.", + "canonical": true, + "file": "datastore.begin_transaction.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 63, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "BeginTransaction", + "fullName": "google.datastore.v1.Datastore.BeginTransaction", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "transaction_options", + "type": ".google.datastore.v1.TransactionOptions" + } + ], + "resultType": ".google.datastore.v1.BeginTransactionResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "BeginTransaction", + "fullName": "google.datastore.v1.Datastore.BeginTransaction", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_Commit_async", + "title": "datastore commit Sample", + "origin": "API_DEFINITION", + "description": " Commits a transaction, optionally creating, deleting or modifying some entities.", + "canonical": true, + "file": "datastore.commit.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 89, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Commit", + "fullName": "google.datastore.v1.Datastore.Commit", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "mode", + "type": ".google.datastore.v1.CommitRequest.Mode" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + }, + { + "name": "single_use_transaction", + "type": ".google.datastore.v1.TransactionOptions" + }, + { + "name": "mutations", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.CommitResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Commit", + "fullName": "google.datastore.v1.Datastore.Commit", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_Rollback_async", + "title": "datastore rollback Sample", + "origin": "API_DEFINITION", + "description": " Rolls back a transaction.", + "canonical": true, + "file": "datastore.rollback.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "Rollback", + "fullName": "google.datastore.v1.Datastore.Rollback", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "transaction", + "type": "TYPE_BYTES" + } + ], + "resultType": ".google.datastore.v1.RollbackResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "Rollback", + "fullName": "google.datastore.v1.Datastore.Rollback", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_AllocateIds_async", + "title": "datastore allocateIds Sample", + "origin": "API_DEFINITION", + "description": " Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.", + "canonical": true, + "file": "datastore.allocate_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "AllocateIds", + "fullName": "google.datastore.v1.Datastore.AllocateIds", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.AllocateIdsResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "AllocateIds", + "fullName": "google.datastore.v1.Datastore.AllocateIds", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + }, + { + "regionTag": "datastore_v1_generated_Datastore_ReserveIds_async", + "title": "datastore reserveIds Sample", + "origin": "API_DEFINITION", + "description": " Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.", + "canonical": true, + "file": "datastore.reserve_ids.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 65, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "ReserveIds", + "fullName": "google.datastore.v1.Datastore.ReserveIds", + "async": true, + "parameters": [ + { + "name": "project_id", + "type": "TYPE_STRING" + }, + { + "name": "database_id", + "type": "TYPE_STRING" + }, + { + "name": "keys", + "type": "TYPE_MESSAGE[]" + } + ], + "resultType": ".google.datastore.v1.ReserveIdsResponse", + "client": { + "shortName": "DatastoreClient", + "fullName": "google.datastore.v1.DatastoreClient" + }, + "method": { + "shortName": "ReserveIds", + "fullName": "google.datastore.v1.Datastore.ReserveIds", + "service": { + "shortName": "Datastore", + "fullName": "google.datastore.v1.Datastore" + } + } + } + } + ] +} diff --git a/handwritten/nodejs-datastore/samples/import.js b/handwritten/nodejs-datastore/samples/import.js new file mode 100644 index 00000000000..f86601971a1 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/import.js @@ -0,0 +1,53 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +async function main(file = 'YOUR_FILE_NAME') { + // [START datastore_admin_entities_import] + const {Datastore} = require('@google-cloud/datastore'); + const datastore = new Datastore(); + + async function importEntities() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const file = 'YOUR_FILE_NAME'; + + const [importOperation] = await datastore.import({file}); + + // Uncomment to await the results of the operation. + // await importOperation.promise(); + + // Or cancel the operation. + await importOperation.cancel(); + + // You may also choose to include only specific kinds and namespaces. + const [specificImportOperation] = await datastore.import({ + file, + kinds: ['Employee', 'Task'], + namespaces: ['Company'], + }); + + // Uncomment to await the results of the operation. + // await specificImportOperation.promise(); + + // Or cancel the operation. + await specificImportOperation.cancel(); + } + + importEntities(); + // [END datastore_admin_entities_import] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/index.yaml b/handwritten/nodejs-datastore/samples/index.yaml new file mode 100644 index 00000000000..3f851a0065c --- /dev/null +++ b/handwritten/nodejs-datastore/samples/index.yaml @@ -0,0 +1,34 @@ +indexes: + +- kind: Task + ancestor: no + properties: + - name: done + - name: priority + direction: desc + +- kind: Task + properties: + - name: priority + direction: desc + - name: created + +- kind: Task + properties: + - name: priority + - name: created + +- kind: Task + properties: + - name: done + - name: created + +- kind: Task + properties: + - name: category + - name: priority + +- kind: Task + properties: + - name: percent_complete + - name: priority diff --git a/handwritten/nodejs-datastore/samples/indexes.get.js b/handwritten/nodejs-datastore/samples/indexes.get.js new file mode 100644 index 00000000000..e434cf5ef87 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/indexes.get.js @@ -0,0 +1,39 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +async function main(indexId = 'YOUR_INDEX_ID') { + // [START datastore_admin_index_get] + const {Datastore} = require('@google-cloud/datastore'); + const datastore = new Datastore(); + + async function getIndex() { + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const indexId = 'YOUR_INDEX_ID'; + + // Create a reference to the index before performing operations on it. + const index = datastore.index(indexId); + + // Get the index's metadata, including its state, properties, and more. + const [metadata] = await index.getMetadata(); + console.log('Properties:', metadata.properties); + } + + getIndex(); + // [END datastore_admin_index_get] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/indexes.list.js b/handwritten/nodejs-datastore/samples/indexes.list.js new file mode 100644 index 00000000000..b061521308a --- /dev/null +++ b/handwritten/nodejs-datastore/samples/indexes.list.js @@ -0,0 +1,45 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +async function main() { + // [START datastore_admin_index_list] + const {Datastore} = require('@google-cloud/datastore'); + const datastore = new Datastore(); + + async function listIndexes() { + const [indexes] = await datastore.getIndexes(); + + console.log(`${indexes.length} indexes returned.`); + + // Each returned Index object includes metadata about the index. + const [firstIndex] = indexes; + console.log('Properties:', firstIndex.metadata.properties); + + // You may also get Index references as a readable object stream. + datastore + .getIndexesStream() + .on('data', index => { + console.log('Properties:', index.metadata.properties); + }) + .on('end', () => { + // All matching Index objects have been returned. + }); + } + + listIndexes(); + // [END datastore_admin_index_list] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/package.json b/handwritten/nodejs-datastore/samples/package.json new file mode 100644 index 00000000000..f4033a80799 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/package.json @@ -0,0 +1,24 @@ +{ + "name": "nodejs-docs-samples-datastore", + "private": true, + "license": "Apache-2.0", + "author": "Google LLC.", + "files": [ + "*.js" + ], + "repository": "googleapis/nodejs-datastore", + "engines": { + "node": ">=18" + }, + "scripts": { + "test": "mocha --timeout=600000" + }, + "dependencies": { + "@google-cloud/datastore": "^10.0.1", + "sinon": "^18.0.0" + }, + "devDependencies": { + "chai": "^4.2.0", + "mocha": "^8.0.0" + } +} \ No newline at end of file diff --git a/handwritten/nodejs-datastore/samples/queryFilterOr.js b/handwritten/nodejs-datastore/samples/queryFilterOr.js new file mode 100644 index 00000000000..deb911d7773 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/queryFilterOr.js @@ -0,0 +1,54 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Create a union between two filters +// description: Create a union between two filters (logical OR operator) + +async function main() { + // [START datastore_query_filter_or] + /** + * TODO(developer): Uncomment these variables before running the sample. + */ + // const projectId = "your Google Cloud project id"; + + // Imports the Cloud Datastore + const {Datastore, PropertyFilter, or} = require('@google-cloud/datastore'); + + async function queryFilterOr() { + // Instantiate the Datastore + const datastore = new Datastore(); + const query = datastore + .createQuery('Task') + .filter( + or([ + new PropertyFilter('description', '=', 'Buy milk'), + new PropertyFilter('description', '=', 'Feed cats'), + ]), + ); + + const [entities] = await datastore.runQuery(query); + for (const entity of entities) { + console.log(`Entity found: ${entity['description']}`); + } + } + + queryFilterOr(); + // [END datastore_query_filter_or] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/queryProfileExplain.js b/handwritten/nodejs-datastore/samples/queryProfileExplain.js new file mode 100644 index 00000000000..c5405a51b80 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/queryProfileExplain.js @@ -0,0 +1,38 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Run query explain (regular query) +// description: Run query explain for a standard query and print query explain metrics + +async function main() { + // [START datastore_query_explain_entity] + + // Imports the Cloud Datastore + const {Datastore} = require('@google-cloud/datastore'); + + // Instantiate the Datastore + const datastore = new Datastore(); + const q = datastore.createQuery('Task'); + const [, info] = await datastore.runQuery(q, { + explainOptions: {analyze: false}, + }); + console.log(`info: ${Object.keys(info.explainMetrics)}`); + // [END datastore_query_explain_entity] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/queryProfileExplainAggregation.js b/handwritten/nodejs-datastore/samples/queryProfileExplainAggregation.js new file mode 100644 index 00000000000..9f192aeafc1 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/queryProfileExplainAggregation.js @@ -0,0 +1,41 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Run query explain (aggregate query) +// description: Run query explain for an aggregate query and print query explain metrics + +async function main() { + // [START datastore_query_explain_aggregation] + + // Imports the Cloud Datastore + const {Datastore, AggregateField} = require('@google-cloud/datastore'); + + // Instantiate the Datastore + const datastore = new Datastore(); + const q = datastore.createQuery('Task'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('created')); + const [, info] = await datastore.runAggregationQuery(aggregate, { + explainOptions: {analyze: false}, + }); + console.log(`info: ${Object.keys(info.explainMetrics)}`); + // [END datastore_query_explain_aggregation] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/queryProfileExplainAnalyze.js b/handwritten/nodejs-datastore/samples/queryProfileExplainAnalyze.js new file mode 100644 index 00000000000..1b9a658ef00 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/queryProfileExplainAnalyze.js @@ -0,0 +1,41 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Run query explain analyze (regular query) +// description: Run query explain analyze for a standard query and print query explain metrics + +async function main() { + // [START datastore_query_explain_analyze_entity] + + // Imports the Cloud Datastore + const {Datastore} = require('@google-cloud/datastore'); + + // Instantiate the Datastore + const datastore = new Datastore(); + const q = datastore.createQuery('Task'); + const [entities, info] = await datastore.runQuery(q, { + explainOptions: {analyze: true}, + }); + for (const entity of entities) { + console.log(`Entity found: ${entity['description']}`); + } + console.log(`info: ${Object.keys(info.explainMetrics)}`); + // [END datastore_query_explain_analyze_entity] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/queryProfileExplainAnalyzeAggregation.js b/handwritten/nodejs-datastore/samples/queryProfileExplainAnalyzeAggregation.js new file mode 100644 index 00000000000..7eb26b6704f --- /dev/null +++ b/handwritten/nodejs-datastore/samples/queryProfileExplainAnalyzeAggregation.js @@ -0,0 +1,45 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Run query explain analyze (aggregate query) +// description: Run query explain analyze for an aggregate query and print query explain metrics + +async function main() { + // [START datastore_query_explain_analyze_aggregation] + + // Imports the Cloud Datastore + const {Datastore, AggregateField} = require('@google-cloud/datastore'); + + // Instantiate the Datastore + const datastore = new Datastore(); + const q = datastore.createQuery('Task'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('created')); + + const [entities, info] = await datastore.runAggregationQuery(aggregate, { + explainOptions: {analyze: true}, + }); + for (const entity of entities) { + console.log(`Entity found: ${JSON.stringify(entity)}`); + } + console.log(`info: ${Object.keys(info.explainMetrics)}`); + // [END datastore_query_explain_analyze_aggregation] +} + +const args = process.argv.slice(2); +main(...args).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/quickstart.js b/handwritten/nodejs-datastore/samples/quickstart.js new file mode 100644 index 00000000000..62ccaec0612 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/quickstart.js @@ -0,0 +1,47 @@ +// Copyright 2016 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +// [START datastore_quickstart] +// Imports the Google Cloud client library +const {Datastore} = require('@google-cloud/datastore'); + +// Creates a client +const datastore = new Datastore(); + +async function quickstart() { + // The kind for the new entity + const kind = 'Task'; + + // The name/ID for the new entity + const name = 'sampletask1'; + + // The Cloud Datastore key for the new entity + const taskKey = datastore.key([kind, name]); + + // Prepares the new entity + const task = { + key: taskKey, + data: { + description: 'Buy milk', + }, + }; + + // Saves the entity + await datastore.save(task); + console.log(`Saved ${task.key.name}: ${task.data.description}`); +} +quickstart(); +// [END datastore_quickstart] diff --git a/handwritten/nodejs-datastore/samples/tasks.add.js b/handwritten/nodejs-datastore/samples/tasks.add.js new file mode 100644 index 00000000000..ba76aa8c307 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/tasks.add.js @@ -0,0 +1,56 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +// sample-metadata: +// title: Add Task +// description: Adds a task with a description . +// usage: node tasks.add.js + +/*eslint no-warning-comments: [0, { "terms": ["todo"], "location": "anywhere" }]*/ +async function main(description) { + // [START datastore_add_entity] + const {Datastore} = require('@google-cloud/datastore'); + const datastore = new Datastore(); + + async function addTask() { + // TODO(developer): uncomment the following line, and add a description + // const description = 'description'; + const taskKey = datastore.key('Task'); + const entity = { + key: taskKey, + data: [ + { + name: 'created', + value: new Date().toJSON(), + }, + { + name: 'description', + value: description, + excludeFromIndexes: true, + }, + { + name: 'done', + value: false, + }, + ], + }; + await datastore.save(entity); + console.log(`Task ${taskKey.id} created successfully.`); + } + addTask(); + // [END datastore_add_entity] +} +main(...process.argv.slice(2)).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/tasks.delete.js b/handwritten/nodejs-datastore/samples/tasks.delete.js new file mode 100644 index 00000000000..c94ef7d8231 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/tasks.delete.js @@ -0,0 +1,42 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +// sample-metadata: +// title: Delete Task +// description: Deletes task . +// usage: node tasks.delete.js + +/*eslint no-warning-comments: [0, { "terms": ["todo"], "location": "anywhere" }]*/ +async function main(taskId) { + taskId = Number(taskId); + // [START datastore_delete_entity] + const {Datastore} = require('@google-cloud/datastore'); + + const datastore = new Datastore(); + + async function deleteTask() { + // TODO(developer): uncomment the following line and define a taskId + // const taskId = 'task123'; + const taskKey = datastore.key(['Task', taskId]); + console.log(taskKey); + await datastore.delete(taskKey); + console.log(`Task ${taskId} deleted successfully.`); + } + deleteTask(); + // [END datastore_delete_entity] +} + +main(...process.argv.slice(2)).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/tasks.js b/handwritten/nodejs-datastore/samples/tasks.js new file mode 100644 index 00000000000..eca5d3be2cb --- /dev/null +++ b/handwritten/nodejs-datastore/samples/tasks.js @@ -0,0 +1,187 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +// sample-metadata: +// title: Legacy Samples + +// [START datastore_build_service] +// By default, the client will authenticate using the service account file +// specified by the GOOGLE_APPLICATION_CREDENTIALS environment variable and use +// the project specified by the GCLOUD_PROJECT environment variable. See +// https://googlecloudplatform.github.io/google-cloud-node/#/docs/datastore/latest/guides/authentication +const {Datastore} = require('@google-cloud/datastore'); + +// Creates a client +const datastore = new Datastore(); +// [END datastore_build_service] + +/* +Installation and setup instructions. +1. Download the TaskList sample application from [here] +(https://github.com/GoogleCloudPlatform/nodejs-docs-samples/archive/master.zip). + +2. Unzip the download: +```sh +unzip nodejs-docs-samples-master.zip +``` + +3. Change directories to the TaskList application: +```sh +cd nodejs-docs-samples-master/datastore +``` + +4. Install the dependencies and link the application: +```sh +npm install +``` + +5. With the gcloud SDK, be sure you are authenticated: +```sh +gcloud beta auth application-default login +``` + +6. At a command prompt, run the following, where `` is the ID of +your Google Cloud Platform project. +```sh +export GCLOUD_PROJECT= +``` + +7. Run the application! +```sh +node tasks +``` +*/ + +// [START datastore_add_entity] +async function addTask(description) { + const taskKey = datastore.key('Task'); + const entity = { + key: taskKey, + data: [ + { + name: 'created', + value: new Date().toJSON(), + }, + { + name: 'description', + value: description, + excludeFromIndexes: true, + }, + { + name: 'done', + value: false, + }, + ], + }; + + try { + await datastore.save(entity); + console.log(`Task ${taskKey.id} created successfully.`); + } catch (err) { + console.error('ERROR:', err); + } +} +// [END datastore_add_entity] + +// [START datastore_update_entity] +async function markDone(taskId) { + const transaction = datastore.transaction(); + const taskKey = datastore.key(['Task', datastore.int(taskId)]); + + try { + await transaction.run(); + const [task] = await transaction.get(taskKey); + task.done = true; + transaction.save({ + key: taskKey, + data: task, + }); + await transaction.commit(); + console.log(`Task ${taskId} updated successfully.`); + } catch (err) { + await transaction.rollback(); + } +} +// [END datastore_update_entity] + +// [START datastore_merge_entity] +async function merge(taskId, description) { + const taskKey = datastore.key(['Task', taskId]); + const task = { + description, + }; + try { + await datastore.merge({ + key: taskKey, + data: task, + }); + console.log(`Task ${taskId} description updated successfully.`); + } catch (err) { + console.error('ERROR:', err); + } +} +// [END datastore_merge_entity] + +// [START datastore_retrieve_entities] +async function listTasks() { + const query = datastore.createQuery('Task').order('created'); + + const [tasks] = await datastore.runQuery(query); + console.log('Tasks:'); + tasks.forEach(task => { + const taskKey = task[datastore.KEY]; + console.log(taskKey.id, task); + }); +} +// [END datastore_retrieve_entities] + +// [START datastore_delete_entity] +async function deleteTask(taskId) { + const taskKey = datastore.key(['Task', datastore.int(taskId)]); + + await datastore.delete(taskKey); + console.log(`Task ${taskId} deleted successfully.`); +} +// [END datastore_delete_entity] + +require(`yargs`) // eslint-disable-line + .command( + 'new ', + 'Adds a task with a description .', + {}, + opts => addTask(opts.description), + ) + .command('done ', 'Marks the specified task as done.', {}, opts => + markDone(opts.taskId), + ) + .command('merge ', 'Marks the specified task as done.', {}, opts => + merge(opts.taskId, opts.description), + ) + .command('list', 'Lists all tasks ordered by creation time.', {}, listTasks) + .command('delete ', 'Deletes a task.', {}, opts => + deleteTask(opts.taskId), + ) + .example('node $0 new "Buy milk"', 'Adds a task with description "Buy milk".') + .example('node $0 done 12345', 'Marks task 12345 as Done.') + .example( + 'node $0 merge 12345', + 'update task 12345 with description "Buy food".', + ) + .example('node $0 list', 'Lists all tasks ordered by creation time') + .example('node $0 delete 12345', 'Deletes task 12345.') + .wrap(120) + .epilogue('For more information, see https://cloud.google.com/datastore/docs') + .help().argv; diff --git a/handwritten/nodejs-datastore/samples/tasks.list.js b/handwritten/nodejs-datastore/samples/tasks.list.js new file mode 100644 index 00000000000..d31633c9565 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/tasks.list.js @@ -0,0 +1,37 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +// sample-metadata: +// title: List Tasks +// description: Lists all tasks ordered by creation time. +// usage: node tasks.list.js + +// [START datastore_retrieve_entities] +const {Datastore} = require('@google-cloud/datastore'); + +const datastore = new Datastore(); + +async function listTasks() { + const query = datastore.createQuery('Task').order('created'); + const [tasks] = await datastore.runQuery(query); + console.log('Tasks:'); + for (const task of tasks) { + const taskKey = task[datastore.KEY]; + console.log(taskKey.id, task); + } +} +listTasks(); +// [END datastore_retrieve_entities] diff --git a/handwritten/nodejs-datastore/samples/tasks.markdone.js b/handwritten/nodejs-datastore/samples/tasks.markdone.js new file mode 100644 index 00000000000..ed64910504f --- /dev/null +++ b/handwritten/nodejs-datastore/samples/tasks.markdone.js @@ -0,0 +1,55 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +// sample-metadata: +// title: Update Task +// description: Marks task as Done. +// usage: node tasks.markdone.js + +/*eslint no-warning-comments: [0, { "terms": ["todo"], "location": "anywhere" }]*/ +async function main(taskId) { + taskId = Number(taskId); + // [START datastore_update_entity] + const {Datastore} = require('@google-cloud/datastore'); + const datastore = new Datastore(); + + async function markDone() { + // TODO(developer): uncomment the following line and define a taskId + // const taskId = 'task123'; + const transaction = datastore.transaction(); + const taskKey = datastore.key(['Task', taskId]); + console.log(taskKey); + console.log(taskKey.path); + try { + await transaction.run(); + const [task] = await transaction.get(taskKey); + task.done = true; + transaction.save({ + key: taskKey, + data: task, + }); + await transaction.commit(); + console.log(`Task ${taskId} updated successfully.`); + } catch (err) { + await transaction.rollback(); + throw err; + } + } + markDone(); + // [END datastore_update_entity] +} + +main(...process.argv.slice(2)).catch(console.error); diff --git a/handwritten/nodejs-datastore/samples/test/concepts.test.js b/handwritten/nodejs-datastore/samples/test/concepts.test.js new file mode 100644 index 00000000000..ef977bd298c --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/concepts.test.js @@ -0,0 +1,164 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +const concepts = require('../concepts'); +const assert = require('assert'); +const {describe, it, before, after} = require('mocha'); + +let transaction; +let metadata; +let index; +let query; +let entity; + +const Transaction = concepts.Transaction; +const Metadata = concepts.Metadata; +const Index = concepts.Index; +const Entity = concepts.Entity; +const Query = concepts.Query; + +describe('concepts', () => { + before(() => { + const projectId = process.env.GCLOUD_PROJECT; + assert.ok(projectId, 'You must set the GCLOUD_PROJECT env var!'); + transaction = new Transaction(projectId); + metadata = new Metadata(projectId); + index = new Index(projectId); + entity = new Entity(projectId); + query = new Query(projectId); + }); + + after(async () => { + const datastore = transaction.datastore; + const query = datastore.createQuery('__kind__').select('__key__'); + const [entities] = await datastore.runQuery(query); + const testKinds = entities.map(entity => entity[datastore.KEY].name); + + async function deleteEntities(kind) { + const query = datastore.createQuery(kind).select('__key__'); + const [entities] = await datastore.runQuery(query); + const keys = entities.map(entity => { + return entity[datastore.KEY]; + }); + await datastore.delete(keys); + } + await Promise.all(testKinds.map(kind => deleteEntities(kind))); + }); + + // Transactions + it('performs a transactional update', () => + transaction.testTransactionalUpdate()); + it('performs retries if necessary', () => + transaction.testTransactionalRetry()); + it('performs a get or create', () => + transaction.testTransactionalGetOrCreate()); + it('gets a snapshot of task list entities', () => + transaction.testSingleEntityGroupReadOnly()); + + // Metadata + it('performs a namespace query', () => metadata.testNamespaceRunQuery()); + it('performs a kind query', () => metadata.testKindRunQuery()); + it('performs a property query', () => metadata.testPropertyRunQuery()); + it('performs a property by kind query', () => + metadata.testPropertyByKindRunQuery()); + + // Indexes + it('performs a query with a filter on an unindexed property', () => + index.testUnindexedPropertyQuery()); + it('inserts arrays of data', () => index.testExplodingProperties()); + + // Queries + it('performs a basic query', async () => await query.testRunQuery()); + it('performs a query with a property filter', () => + query.testPropertyFilter()); + it('performs a query with a composite filter', () => + query.testCompositeFilter()); + it('performs a query with a key filter', () => query.testKeyFilter()); + it('performs a query with ascending sort', () => query.testAscendingSort()); + it('performs a query with descending sort', () => query.testDescendingSort()); + it('performs a query with multi sort', () => query.testMultiSort()); + it('performs a kindless query', () => query.testKindlessQuery()); + it('performs a projection query', () => { + return entity + .testProperties() + .then(() => { + return new Promise((resolve, reject) => { + setTimeout(() => { + query.testRunQueryProjection().then(resolve, reject); + }, 1000); + }); + }) + .then(results => { + assert.deepStrictEqual(results, { + priorities: [4], + percentCompletes: [10], + }); + }); + }); + it('performs a keys only query', () => query.testKeysOnlyQuery()); + it('performs a distinct on query', () => query.testDistinctOnQuery()); + it('performs an array value inequality query', () => + query.testArrayValueInequalityRange()); + it('performs an array value equality query', () => + query.testArrayValueEquality()); + it('performs an inequality range query', () => query.testInequalityRange()); + it('returns an error from an invalid query', async () => { + await assert.throws(query.testInequalityInvalid); + }); + it('performs an equal and inequality range query', () => + query.testEqualAndInequalityRange()); + it('performs an equality sort query', () => query.testInequalitySort()); + it('returns an error when not sorted on filtered property', async () => { + await assert.throws(query.testInequalitySortInvalidNotSame); + }); + it('returns an error when not sorted on first filter prop', async () => { + await assert.throws(query.testInequalitySortInvalidNotFirst); + }); + it('performs a query with a limit', () => query.testLimit()); + it('allows manual pagination through results', () => { + return entity.testBatchUpsert().then(() => { + return new Promise((resolve, reject) => { + setTimeout(() => { + query.testCursorPaging().then(resolve, reject); + }, 1000); + }); + }); + }); + it('performs an ancestor query', () => query.testEventualConsistentQuery()); + + // Entities + it('saves with an incomplete key', () => entity.testIncompleteKey()); + it('saves with a named key', () => entity.testNamedKey()); + it('saves a key with a parent', () => entity.testKeyWithParent()); + it('saves a key with multiple parents', () => + entity.testKeyWithMultiLevelParent()); + it('saves an entity with a parent', () => entity.testEntityWithParent()); + it('saves an entity with properties', () => { + return entity.testProperties(); + }); + it('saves an entity with arrays', () => entity.testArrayValue()); + it('saves a basic entity', () => entity.testBasicEntity()); + it('saves with an upsert', () => entity.testUpsert()); + it('saves with an insert', () => entity.testInsert()); + it('performs a lookup', () => entity.testLookup()); + it('saves with an update', () => entity.testUpdate()); + it('deletes an entity', () => entity.testDelete()); + it('performs a batch upsert', () => { + return entity.testBatchUpsert(); + }); + it('performs a batch lookup', () => entity.testBatchLookup()); + it('performs a batch delete', () => entity.testBatchDelete()); +}); diff --git a/handwritten/nodejs-datastore/samples/test/error.test.js b/handwritten/nodejs-datastore/samples/test/error.test.js new file mode 100644 index 00000000000..7aa2f3f77eb --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/error.test.js @@ -0,0 +1,32 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +const assert = require('assert'); +const {describe, it} = require('mocha'); +const {execSync} = require('child_process'); +const exec = cmd => + execSync(cmd, { + encoding: 'utf8', + }); + +describe('error', () => { + it('should have an error', done => { + const errorCode = 3; + const output = exec('node error.js'); + assert.strictEqual(parseInt(output[0]), errorCode); + done(); + }); +}); diff --git a/handwritten/nodejs-datastore/samples/test/helpers/populate-data.js b/handwritten/nodejs-datastore/samples/test/helpers/populate-data.js new file mode 100644 index 00000000000..85d19dbdf4b --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/helpers/populate-data.js @@ -0,0 +1,56 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +/* eslint-disable */ + +/* +This module is used in various samples to set datastore data to a fixed state +so that the output of the sample is predictable. + */ + +const {after, before} = require('mocha'); +const {Datastore} = require('@google-cloud/datastore'); +let taskKey1, taskKey2; +const datastore = new Datastore(); + +before(async () => { + taskKey1 = datastore.key('Task'); + const entity1 = { + key: taskKey1, + data: { + description: 'Buy milk', + }, + }; + + taskKey2 = datastore.key('Task'); + const entity2 = { + key: taskKey2, + data: { + description: 'Feed cats', + }, + }; + + // Ensure the datastore database has no existing data. + const query = datastore.createQuery('Task'); + const [entities] = await datastore.runQuery(query); + await datastore.delete(entities.map(entity => entity[datastore.KEY])); + + await datastore.upsert(entity1); + await datastore.upsert(entity2); +}); + +after(async () => { + await datastore.delete(taskKey1); + await datastore.delete(taskKey2); +}); diff --git a/handwritten/nodejs-datastore/samples/test/helpers/sorting.js b/handwritten/nodejs-datastore/samples/test/helpers/sorting.js new file mode 100644 index 00000000000..47749dd1ed8 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/helpers/sorting.js @@ -0,0 +1,22 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +// This function is used for comparing console output when the +// order of the console output doesn't matter. + +function sortConsoleOutput(output) { + return output.split('\n').sort().join('\n'); +} + +module.exports = sortConsoleOutput; diff --git a/handwritten/nodejs-datastore/samples/test/import-export.test.js b/handwritten/nodejs-datastore/samples/test/import-export.test.js new file mode 100644 index 00000000000..7471da3e9cd --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/import-export.test.js @@ -0,0 +1,46 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +const {Datastore} = require('@google-cloud/datastore'); +const {assert} = require('chai'); +const cp = require('child_process'); +const {before, describe, it} = require('mocha'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('import/export entities', async () => { + const datastore = new Datastore(); + + const BUCKET_ID = 'nodejs-datastore-system-tests'; + let EXPORTED_FILE; + + before(async () => { + const [exportOperation] = await datastore.export({ + bucket: BUCKET_ID, + }); + await exportOperation.promise(); + EXPORTED_FILE = exportOperation.result.outputUrl; + }); + + it('should export entities', async () => { + const stdout = execSync(`node ./export.js ${BUCKET_ID}`); + assert.include(stdout, 'Export file created:'); + }); + + it.skip('should import entities', () => { + execSync(`node ./import.js ${EXPORTED_FILE}`); + }); +}); diff --git a/handwritten/nodejs-datastore/samples/test/index.yaml b/handwritten/nodejs-datastore/samples/test/index.yaml new file mode 100644 index 00000000000..178a98dd504 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/index.yaml @@ -0,0 +1,36 @@ +indexes: +- kind: Task + properties: + - name: done + - name: priority + direction: desc +- kind: Task + properties: + - name: priority + - name: percent_complete +- kind: Task + properties: + - name: category + - name: priority +- kind: Task + properties: + - name: priority + - name: created +- kind: Task + properties: + - name: done + - name: created +- kind: Task + properties: + - name: category + - name: priority + direction: desc +- kind: Task + properties: + - name: category + - name: created +- kind: Task + properties: + - name: priority + direction: desc + - name: created diff --git a/handwritten/nodejs-datastore/samples/test/indexes.test.js b/handwritten/nodejs-datastore/samples/test/indexes.test.js new file mode 100644 index 00000000000..b1bab339039 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/indexes.test.js @@ -0,0 +1,41 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +const {Datastore} = require('@google-cloud/datastore'); +const {assert} = require('chai'); +const cp = require('child_process'); +const {describe, it} = require('mocha'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('indexes', async () => { + const datastore = new Datastore(); + + // @TODO: Until the protos support creating indexes, these tests depend on + // the remote state of declared indexes. Could be flaky! + + it('should list indexes', async () => { + const [indexes] = await datastore.getIndexes(); + const stdout = execSync('node ./indexes.list.js'); + assert.include(stdout, `${indexes.length} indexes returned.`); + }); + + it('should get a specific index', async () => { + const [indexes] = await datastore.getIndexes(); + const stdout = execSync(`node ./indexes.get.js ${indexes[0].id}`); + assert.include(stdout, 'Properties:'); + }); +}); diff --git a/handwritten/nodejs-datastore/samples/test/queryFilterOr.test.js b/handwritten/nodejs-datastore/samples/test/queryFilterOr.test.js new file mode 100644 index 00000000000..c1aa990ee1a --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/queryFilterOr.test.js @@ -0,0 +1,48 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +/* eslint-disable */ + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); +const sinon = require('sinon'); +// TODO: delete unused imports + +const cp = require('child_process'); +const sort = require('./helpers/sorting'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('Creating a union query', () => { + const stubConsole = function () { + sinon.stub(console, 'error'); + sinon.stub(console, 'log'); + }; + + const restoreConsole = function () { + console.log.restore(); + console.error.restore(); + }; + + beforeEach(stubConsole); + afterEach(restoreConsole); + + require('./helpers/populate-data'); + + it('should get a combination of items from the Datastore', async () => { + assert.strictEqual(sort(execSync(`node ./queryFilterOr.js`)), '\nEntity found: Buy milk\nEntity found: Feed cats'); + }); +}); diff --git a/handwritten/nodejs-datastore/samples/test/queryProfiling.test.js b/handwritten/nodejs-datastore/samples/test/queryProfiling.test.js new file mode 100644 index 00000000000..2a096017131 --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/queryProfiling.test.js @@ -0,0 +1,45 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +/* eslint-disable */ + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); + +const cp = require('child_process'); +const sort = require('./helpers/sorting'); + +const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); + +describe('Query Profiling', () => { + require('./helpers/populate-data'); + + it('should run query profiling for a query with analyze set to false', async () => { + assert.strictEqual(sort(execSync(`node ./queryProfileExplain.js`)), '\ninfo: planSummary'); + }); + + it('should run query profiling for an aggregation query with analyze set to false', async () => { + assert.strictEqual(sort(execSync(`node ./queryProfileExplainAggregation.js`)), '\ninfo: planSummary'); + }); + + it('should run query profiling for a query with analyze set to true', async () => { + assert.strictEqual(sort(execSync(`node ./queryProfileExplainAnalyze.js`)), '\nEntity found: Buy milk\nEntity found: Feed cats\ninfo: planSummary,executionStats'); + }); + + it('should run query profiling for an aggregation query with analyze set to true', async () => { + assert.strictEqual(sort(execSync(`node ./queryProfileExplainAnalyzeAggregation.js`)), '\nEntity found: {"property_1":0}\ninfo: planSummary,executionStats'); + }); +}); diff --git a/handwritten/nodejs-datastore/samples/test/quickstart.test.js b/handwritten/nodejs-datastore/samples/test/quickstart.test.js new file mode 100644 index 00000000000..1334edf96aa --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/quickstart.test.js @@ -0,0 +1,28 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); +const {execSync} = require('child_process'); + +const exec = cmd => execSync(cmd, {encoding: 'utf8'}); + +describe('quickstart', () => { + it('should run the quickstart', () => { + const output = exec('node quickstart.js'); + assert.include(output, 'Saved sampletask1: Buy milk'); + }); +}); diff --git a/handwritten/nodejs-datastore/samples/test/tasks.test.js b/handwritten/nodejs-datastore/samples/test/tasks.test.js new file mode 100644 index 00000000000..ee09b1c2f1f --- /dev/null +++ b/handwritten/nodejs-datastore/samples/test/tasks.test.js @@ -0,0 +1,61 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +'use strict'; + +const {Datastore} = require('@google-cloud/datastore'); +const {assert} = require('chai'); +const {describe, it, after} = require('mocha'); +const {execSync} = require('child_process'); + +const exec = cmd => execSync(cmd, {encoding: 'utf8'}); +const datastore = new Datastore(); +const description = 'description'; +let key; + +describe('task samples', () => { + after(() => datastore.delete(key).catch()); + + it('should add a task', async () => { + const expected = /^Task (\d+) created successfully.$/; + const output = exec(`node tasks.add.js "${description}"`).trim(); + const parts = output.match(expected); + assert.match(parts[0], expected); + const keyId = Number(parts[1]); + const [task] = await datastore.get(datastore.key(['Task', keyId])); + key = task[datastore.KEY]; + assert.strictEqual(task.description, description); + }); + + it('should mark a task as done', async () => { + const expected = `Task ${key.id} updated successfully.`; + const output = exec(`node tasks.markdone.js ${key.id}`); + assert.include(output, expected); + const [task] = await datastore.get(key); + assert.strictEqual(task.done, true); + }); + + it('should list tasks', () => { + const output = exec('node tasks.list.js'); + assert.include(output, key.id); + }); + + it('should delete a task', async () => { + const expected = `Task ${key.id} deleted successfully.`; + const output = exec(`node tasks.delete.js ${key.id}`); + assert.include(output, expected); + const [task] = await datastore.get(key); + assert.strictEqual(task, undefined); + }); +}); diff --git a/handwritten/nodejs-datastore/src/aggregate.ts b/handwritten/nodejs-datastore/src/aggregate.ts new file mode 100644 index 00000000000..3c07aeee3c1 --- /dev/null +++ b/handwritten/nodejs-datastore/src/aggregate.ts @@ -0,0 +1,257 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import {Query} from './index'; +import {RunQueryOptions, RunQueryResponse} from './query'; +import {RequestCallback} from './request'; +const AGGREGATE_QUERY = Symbol('AGGREGATE_QUERY'); + +/** + * An AggregateQuery is a class that can be used to obtain results from an + * aggregate query request. + * + * @see {@link https://cloud.google.com/datastore/docs/aggregation-queries| Aggregation queries Reference} + * + * @class + */ +class AggregateQuery { + type = AGGREGATE_QUERY; + aggregations: Array; + query: Query | undefined; + + /** + * Build an AggregateQuery object. + * + * @param {Query} query A Query object + */ + constructor(query: Query) { + this.query = query; + this.aggregations = []; + } + + /** + * Add a `count` aggregate query to the list of aggregations. + * + * @param {string} alias The label used in the results to describe this + * aggregate field when a query is run. + * @returns {AggregateQuery} + */ + count(alias?: string): AggregateQuery { + this.aggregations.push(AggregateField.count().alias(alias)); + return this; + } + + /** + * Add a `sum` aggregate query to the list of aggregations. + * + * @param {string} property The property to use for the sum calculation. + * @param {string} alias The label used in the results to describe this + * aggregate field when a query is run. + * @returns {AggregateQuery} + */ + sum(property: string, alias?: string): AggregateQuery { + this.aggregations.push(AggregateField.sum(property).alias(alias)); + return this; + } + + /** + * Add a `average` aggregate query to the list of aggregations. + * + * @param {string} property The property to use for the average calculation. + * @param {string} alias The label used in the results to describe this + * aggregate field when a query is run. + * @returns {AggregateQuery} + */ + average(property: string, alias?: string): AggregateQuery { + this.aggregations.push(AggregateField.average(property).alias(alias)); + return this; + } + + /** + * Add a custom aggregation to the list of aggregations. + * + * @param {AggregateField} aggregation The aggregate field to perform the + * aggregation query over. + * @returns {AggregateQuery} + */ + addAggregation(aggregation: AggregateField): AggregateQuery { + this.aggregations.push(aggregation); + return this; + } + + /** + * Add a list of custom aggregations to the list of aggregations. + * + * @param {AggregateField[]} aggregations The aggregate fields to perform the + * aggregation query over. + * @returns {AggregateQuery} + */ + addAggregations(aggregations: AggregateField[]): AggregateQuery { + for (const aggregation of aggregations) { + this.aggregations.push(aggregation); + } + return this; + } + + /** + * Run the aggregation query and return the results. + * + * @param {RunQueryOptions | RequestCallback} [optionsOrCallback] + * @param {function} cb The callback function. + * @returns {void | Promise} + */ + run( + optionsOrCallback?: RunQueryOptions | RequestCallback, + cb?: RequestCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + const scope = this.query!.scope; + const runAggregationQuery = scope!.runAggregationQuery.bind(scope); + return runAggregationQuery(this, options, callback); + } + + /** + * Get the proto for the list of aggregations. + * + */ + toProto(): any { + return this.aggregations.map(aggregation => aggregation.toProto()); + } +} + +/** + * An AggregateField is a class that contains data that defines an aggregation. + * + */ +abstract class AggregateField { + alias_?: string; + + /** + * Gets a copy of the Count aggregate field. + * + * @returns {Count} + */ + static count(): Count { + return new Count(); + } + + /** + * Gets a copy of the Sum aggregate field. + * + * @param {string} property The property to use for the average calculation. + * @returns {Sum} + */ + static sum(property: string): Sum { + return new Sum(property); + } + + /** + * Gets a copy of the Average aggregate field. + * + * @param {string} property The property to use for the average calculation. + * @returns {Average} + */ + static average(property: string): Average { + return new Average(property); + } + + /** + * Sets the alias on the aggregate field that should be used. + * + * @param {string} alias The label used in the results to describe this + * aggregate field when a query is run. + * @returns {AggregateField} + */ + alias(alias?: string): AggregateField { + if (alias) { + this.alias_ = alias; + } + return this; + } + + /** + * Gets the proto for the aggregate field. + * + */ + abstract toProto(): any; +} + +/** + * A Count is a class that contains data that defines a Count aggregation. + * + */ +class Count extends AggregateField { + /** + * Gets the proto for the count aggregate field. + * + */ + toProto(): any { + const count = Object.assign({}); + return Object.assign({count}, this.alias_ ? {alias: this.alias_} : null); + } +} + +/** + * A PropertyAggregateField is a class that contains data that defines any + * aggregation that is performed on a property. + * + */ +abstract class PropertyAggregateField extends AggregateField { + abstract operator: string; + + /** + * Build a PropertyAggregateField object. + * + * @param {string} property The property to aggregate over. + */ + constructor(public property_: string) { + super(); + } + + /** + * Gets the proto for the property aggregate field. + * + */ + toProto(): any { + const aggregation = this.property_ + ? {property: {name: this.property_}} + : {}; + return Object.assign( + {operator: this.operator}, + this.alias_ ? {alias: this.alias_} : null, + {[this.operator]: aggregation}, + ); + } +} + +/** + * A Sum is a class that contains data that defines a Sum aggregation. + * + */ +class Sum extends PropertyAggregateField { + operator = 'sum'; +} + +/** + * An Average is a class that contains data that defines an Average aggregation. + * + */ +class Average extends PropertyAggregateField { + operator = 'avg'; +} + +export {AggregateField, AggregateQuery, AGGREGATE_QUERY}; diff --git a/handwritten/nodejs-datastore/src/entity.ts b/handwritten/nodejs-datastore/src/entity.ts new file mode 100644 index 00000000000..b5c376724e5 --- /dev/null +++ b/handwritten/nodejs-datastore/src/entity.ts @@ -0,0 +1,1501 @@ +/* eslint-disable no-inner-declarations */ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import arrify = require('arrify'); +import * as extend from 'extend'; +import * as is from 'is'; +import {Query, QueryProto, IntegerTypeCastOptions} from './query'; +import {PathType} from '.'; +import * as Protobuf from 'protobufjs'; +import * as path from 'path'; +import {google} from '../protos/protos'; +import {and, PropertyFilter} from './filter'; + +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace entity { + export interface InvalidKeyErrorOptions { + code: string; + } + + export class InvalidKeyError extends Error { + constructor(opts: InvalidKeyErrorOptions) { + const errorMessages = { + MISSING_KIND: 'A key should contain at least a kind.', + MISSING_ANCESTOR_ID: 'Ancestor keys require an id or name.', + } as {[index: string]: string}; + super(errorMessages[opts.code]); + this.name = 'InvalidKey'; + } + } + + /** + * A symbol to access the Key object from an entity object. + * + * @type {symbol} + * @private + */ + export const KEY_SYMBOL: unique symbol = Symbol('KEY'); + + /** + * Build a Datastore Double object. For long doubles, a string can be + * provided. + * + * @class + * @param {number} value The double value. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const aDouble = datastore.double(7.3); + * ``` + */ + export class Double { + type: string; + value: number; + constructor(value: number) { + /** + * @name Double#type + * @type {string} + */ + this.type = 'DatastoreDouble'; + /** + * @name Double#value + * @type {number} + */ + this.value = value; + } + } + + /** + * Check if something is a Datastore Double object. + * + * @private + * @param {*} value The value to check if it is a datastore double. + * @returns {boolean} + */ + export function isDsDouble(value?: {}): value is entity.Double { + return value instanceof entity.Double; + } + + /** + * Check if a value is a Datastore Double object converted from JSON. + * + * @private + * @param {*} value The value to check if it is datastore double like. + * @returns {boolean} + */ + export function isDsDoubleLike(value: unknown) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const maybeDsDouble = value as any; + return ( + isDsDouble(maybeDsDouble) || + (is.object(maybeDsDouble) && + is.number(maybeDsDouble.value) && + maybeDsDouble.type === 'DatastoreDouble') + ); + } + + /** + * Build a Datastore Int object. For long integers, a string can be provided. + * + * @class + * @param {number|string} value The integer value. + * @param {object} [typeCastOptions] Configuration to convert + * values of `integerValue` type to a custom value. Must provide an + * `integerTypeCastFunction` to handle `integerValue` conversion. + * @param {function} typeCastOptions.integerTypeCastFunction A custom user + * provided function to convert `integerValue`. + * @param {string|string[]} [typeCastOptions.properties] `Entity` property + * names to be converted using `integerTypeCastFunction`. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const anInt = datastore.int(7); + * ``` + */ + export class Int extends Number { + type: string; + value: string; + typeCastFunction?: Function; + typeCastProperties?: string[]; + private _entityPropertyName: string | undefined; + constructor( + value: number | string | ValueProto, + typeCastOptions?: IntegerTypeCastOptions, + ) { + super(typeof value === 'object' ? value.integerValue : value); + this._entityPropertyName = + typeof value === 'object' ? value.propertyName : undefined; + this.value = + typeof value === 'object' + ? value.integerValue.toString() + : value.toString(); + /** + * @name Int#type + * @type {string} + */ + this.type = 'DatastoreInt'; + /** + * @name Int#value + * @type {string} + */ + if (typeCastOptions) { + this.typeCastFunction = typeCastOptions.integerTypeCastFunction; + if (typeof typeCastOptions.integerTypeCastFunction !== 'function') { + throw new Error( + 'integerTypeCastFunction is not a function or was not provided.', + ); + } + + this.typeCastProperties = typeCastOptions.properties + ? arrify(typeCastOptions.properties) + : undefined; + } + } + // eslint-disable-next-line @typescript-eslint/no-explicit-any + valueOf(): any { + let shouldCustomCast = this.typeCastFunction ? true : false; + if ( + this.typeCastProperties && + !this.typeCastProperties.includes(this._entityPropertyName!) + ) { + shouldCustomCast = false; + } + + if (shouldCustomCast) { + try { + return this.typeCastFunction!(this.value); + } catch (error) { + (error as Error).message = + `integerTypeCastFunction threw an error:\n\n - ${ + (error as Error).message + }`; + throw error; + } + } else { + return decodeIntegerValue({ + integerValue: this.value, + propertyName: this._entityPropertyName, + }); + } + } + + toJSON(): Json { + return {type: this.type, value: this.value}; + } + } + + /** + * Check if something is a Datastore Int object. + * + * @private + * @param {*} value The value to check if it is a Datastore Int + * @returns {boolean} + */ + export function isDsInt(value?: {}): value is entity.Int { + return value instanceof entity.Int; + } + + /** + * Check if a value is a Datastore Int object converted from JSON. + * + * @private + * @param {*} value The value to check if it is Datastore IntLike + * @returns {boolean} + */ + export function isDsIntLike(value: unknown) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const maybeDsInt = value as any; + return ( + isDsInt(maybeDsInt) || + (is.object(maybeDsInt) && + is.string(maybeDsInt.value) && + maybeDsInt.type === 'DatastoreInt') + ); + } + + export interface Coordinates { + latitude: number; + longitude: number; + } + + /** + * Build a Datastore Geo Point object. + * + * @class + * @param {object} coordinates Coordinate value. + * @param {number} coordinates.latitude Latitudinal value. + * @param {number} coordinates.longitude Longitudinal value. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const coordinates = { + * latitude: 40.6894, + * longitude: -74.0447 + * }; + * + * const geoPoint = datastore.geoPoint(coordinates); + * ``` + */ + export class GeoPoint { + value: Coordinates; + constructor(coordinates: Coordinates) { + /** + * Coordinate value. + * + * @name GeoPoint#coordinates + * @type {object} + * @property {number} latitude Latitudinal value. + * @property {number} longitude Longitudinal value. + */ + this.value = coordinates; + } + } + + /** + * Check if something is a Datastore Geo Point object. + * + * @private + * @param {*} value The value to check if it is a Geo point. + * @returns {boolean} + */ + export function isDsGeoPoint(value?: {}): value is entity.GeoPoint { + return value instanceof entity.GeoPoint; + } + + export interface KeyOptions { + namespace?: string; + path: PathType[]; + } + + /** + * Build a Datastore Key object. + * + * @class + * @param {object} options Configuration object. + * @param {array} options.path Key path. + * @param {string} [options.namespace] Optional namespace. + * + * @example + * ``` + * //- + * // Create an incomplete key with a kind value of `Company`. + * //- + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key('Company'); + * + * ``` + * @example + * ``` + * //- + * // Create a complete key with a kind value of `Company` and id`123`. + * //- + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key(['Company', 123]); + * + * ``` + * @example + * ``` + * //- + * // If the ID integer is outside the bounds of a JavaScript Number + * // object, create an Int. + * //- + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key([ + * 'Company', + * datastore.int('100000000000001234') + * ]); + * + * ``` + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * // Create a complete key with a kind value of `Company` and name `Google`. + * // Note: `id` is used for numeric identifiers and `name` is used otherwise. + * const key = datastore.key(['Company', 'Google']); + * + * ``` + * @example + * ``` + * //- + * // Create a complete key from a provided namespace and path. + * //- + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key({ + * namespace: 'My-NS', + * path: ['Company', 123] + * }); + * + * ``` + * @example Serialize the key for later re-use. + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key({ + * namespace: 'My-NS', + * path: ['Company', 123] + * }); + * // Later... + * const key = datastore.key(key.serialized); + * ``` + */ + export class Key { + namespace?: string; + id?: string; + name?: string; + kind: string; + parent?: Key; + path!: Array; + + constructor(options: KeyOptions) { + /** + * @name Key#namespace + * @type {string} + */ + this.namespace = options.namespace; + + options.path = [].slice.call(options.path); + + if (options.path.length % 2 === 0) { + const identifier = options.path.pop(); + + if ( + is.number(identifier) || + isDsInt(identifier) || + isDsIntLike(identifier) + ) { + this.id = ((identifier as {} as Int).value || identifier) as string; + } else if (is.string(identifier)) { + this.name = identifier as string; + } + } + + this.kind = options.path.pop() as string; + + if (options.path.length > 0) { + this.parent = new Key(options); + } + + // `path` is computed on demand to consider any changes that may have been + // made to the key. + /** + * @name Key#path + * @type {array} + */ + Object.defineProperty(this, 'path', { + enumerable: true, + get() { + return arrify(this.parent && this.parent.path).concat([ + this.kind, + this.name || this.id, + ]); + }, + }); + } + + /** + * Access the `serialized` property for a library-compatible way to re-use a + * key. + * + * @returns {object} + * + * @example + * ``` + * const key = datastore.key({ + * namespace: 'My-NS', + * path: ['Company', 123] + * }); + * + * // Later... + * const key = datastore.key(key.serialized); + * ``` + */ + get serialized() { + const serializedKey = { + namespace: this.namespace, + path: [this.kind, this.name || new Int(this.id!)], + }; + + if (this.parent) { + serializedKey.path = this.parent.serialized.path.concat( + serializedKey.path, + ); + } + + return serializedKey; + } + } + + /** + * Check if something is a Datastore Key object. + * + * @private + * @param {*} value + * @returns {boolean} + */ + export function isDsKey(value?: {}): value is entity.Key { + return value instanceof entity.Key; + } + + /** + * Convert a protobuf `integerValue`. + * + * @private + * @param {object} value The `integerValue` to convert. + */ + function decodeIntegerValue(value: ValueProto) { + const num = Number(value.integerValue); + if (!Number.isSafeInteger(num)) { + throw new Error( + 'We attempted to return all of the numeric values, but ' + + (value.propertyName ? value.propertyName + ' ' : '') + + 'value ' + + value.integerValue + + " is out of bounds of 'Number.MAX_SAFE_INTEGER'.\n" + + "To prevent this error, please consider passing 'options.wrapNumbers=true' or\n" + + "'options.wrapNumbers' as\n" + + '{\n' + + ' integerTypeCastFunction: provide \n' + + ' properties: optionally specify property name(s) to be custom casted\n' + + '}\n', + ); + } + return num; + } + + /** + * @typedef {object} IntegerTypeCastOptions Configuration to convert + * values of `integerValue` type to a custom value. Must provide an + * `integerTypeCastFunction` to handle `integerValue` conversion. + * @property {function} integerTypeCastFunction A custom user + * provided function to convert `integerValue`. + * @property {string | string[]} [properties] `Entity` property + * names to be converted using `integerTypeCastFunction`. + */ + /** + * Convert a protobuf Value message to its native value. + * + * @private + * @param {object} valueProto The protobuf Value message to convert. + * @param {boolean | IntegerTypeCastOptions} [wrapNumbers=false] Wrap values of integerValue type in + * {@link Datastore#Int} objects. + * If a `boolean`, this will wrap values in {@link Datastore#Int} objects. + * If an `object`, this will return a value returned by + * `wrapNumbers.integerTypeCastFunction`. + * Please see {@link IntegerTypeCastOptions} for options descriptions. + * @returns {*} + * + * @example + * ``` + * decodeValueProto({ + * booleanValue: false + * }); + * // false + * + * decodeValueProto({ + * stringValue: 'Hi' + * }); + * // 'Hi' + * + * decodeValueProto({ + * blobValue: Buffer.from('68656c6c6f') + * }); + * // + * ``` + */ + export function decodeValueProto( + valueProto: ValueProto, + wrapNumbers?: boolean | IntegerTypeCastOptions, + ) { + const valueType = valueProto.valueType!; + const value = valueProto[valueType]; + + switch (valueType) { + case 'arrayValue': { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return value.values.map((val: any) => + entity.decodeValueProto(val, wrapNumbers), + ); + } + + case 'blobValue': { + return Buffer.from(value, 'base64'); + } + + case 'nullValue': { + return null; + } + + case 'doubleValue': { + return Number(value); + } + + case 'integerValue': { + return wrapNumbers + ? typeof wrapNumbers === 'object' + ? new entity.Int(valueProto, wrapNumbers).valueOf() + : new entity.Int(valueProto, undefined) + : decodeIntegerValue(valueProto); + } + + case 'entityValue': { + return entity.entityFromEntityProto(value, wrapNumbers); + } + + case 'keyValue': { + return entity.keyFromKeyProto(value); + } + + case 'timestampValue': { + const milliseconds = Number(value.nanos) / 1e6; + return new Date(Number(value.seconds) * 1000 + milliseconds); + } + + default: { + return value; + } + } + } + + /** + * Convert any native value to a protobuf Value message object. + * + * @private + * @param {*} value Native value. + * @param {string} property The property to use for the average calculation. + * @returns {object} + * + * @example + * ``` + * encodeValue('Hi'); + * // { + * // stringValue: 'Hi' + * // } + * ``` + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function encodeValue(value: any, property: string): ValueProto { + const valueProto: ValueProto = {}; + + if (is.boolean(value)) { + valueProto.booleanValue = value; + return valueProto; + } + + if (is.null(value)) { + valueProto.nullValue = 0; + return valueProto; + } + + if (typeof value === 'number') { + if (Number.isInteger(value)) { + if (!Number.isSafeInteger(value)) { + process.emitWarning( + 'IntegerOutOfBoundsWarning: ' + + "the value for '" + + property + + "' property is outside of bounds of a JavaScript Number.\n" + + "Use 'Datastore.int()' to preserve accuracy during the upload.", + ); + } + value = new entity.Int(value); + } else { + value = new entity.Double(value); + } + } + + if (isDsInt(value)) { + valueProto.integerValue = value.value; + return valueProto; + } + + if (isDsDouble(value)) { + valueProto.doubleValue = value.value; + return valueProto; + } + + if (isDsGeoPoint(value)) { + valueProto.geoPointValue = value.value; + return valueProto; + } + + if (value instanceof Date) { + const seconds = value.getTime() / 1000; + + valueProto.timestampValue = { + seconds: Math.floor(seconds), + nanos: value.getMilliseconds() * 1e6, + }; + + return valueProto; + } + + if (is.string(value)) { + valueProto.stringValue = value; + return valueProto; + } + + if (value instanceof Buffer) { + valueProto.blobValue = value; + return valueProto; + } + + if (Array.isArray(value)) { + valueProto.arrayValue = { + values: value.map(val => entity.encodeValue(val, property)), + }; + return valueProto; + } + + if (isDsKey(value)) { + valueProto.keyValue = entity.keyToKeyProto(value); + return valueProto; + } + + if (is.object(value)) { + if (!is.empty(value)) { + value = extend(true, {}, value); + + for (const prop in value) { + value[prop] = entity.encodeValue(value[prop], prop); + } + } + + valueProto.entityValue = { + properties: value, + }; + + return valueProto; + } + + throw new Error('Unsupported field value, ' + value + ', was provided.'); + } + + /** + * Convert any entity protocol to a plain object. + * + * @todo Use registered metadata if provided. + * + * @private + * @param {object} entityProto The protocol entity object to convert. + * @param {boolean | IntegerTypeCastOptions} [wrapNumbers=false] Wrap values of integerValue type in + * {@link Datastore#Int} objects. + * If a `boolean`, this will wrap values in {@link Datastore#Int} objects. + * If an `object`, this will return a value returned by + * `wrapNumbers.integerTypeCastFunction`. + * Please see {@link IntegerTypeCastOptions} for options descriptions. + * @returns {object} + * + * @example + * ``` + * entityFromEntityProto({ + * properties: { + * map: { + * name: { + * value: { + * valueType: 'stringValue', + * stringValue: 'Stephen' + * } + * } + * } + * } + * }); + * // { + * // name: 'Stephen' + * // } + * ``` + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function entityFromEntityProto( + entityProto: EntityProto, + wrapNumbers?: boolean | IntegerTypeCastOptions, + ) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const entityObject: any = {}; + const properties = entityProto.properties || {}; + + for (const property in properties) { + const value = properties[property]; + value.propertyName = property; + entityObject[property] = entity.decodeValueProto(value, wrapNumbers); + } + + return entityObject; + } + + /** + * Convert an entity object to an entity protocol object. + * + * @private + * @param {object} entityObject The entity object to convert. + * @returns {object} + * + * @example + * ``` + * entityToEntityProto({ + * excludeFromIndexes: [ + * 'name' + * ], + * data: { + * name: 'Burcu', + * legit: true + * } + * }); + * // { + * // key: null, + * // properties: { + * // name: { + * // stringValue: 'Burcu' + * // excludeFromIndexes: true + * // }, + * // legit: { + * // booleanValue: true + * // } + * // } + * // } + * ``` + */ + export function entityToEntityProto(entityObject: EntityObject): EntityProto { + const properties = entityObject.data; + + const entityProto: EntityProto = { + key: null, + + properties: Object.keys(properties).reduce( + (encoded, key) => { + encoded[key] = entity.encodeValue(properties[key], key); + return encoded; + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + {} as any, + ), + }; + + addExcludeFromIndexes(entityObject.excludeFromIndexes, entityProto); + + return entityProto; + } + + /** + * + * @param {string[] | undefined} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entityProto The protocol entity object to convert. + */ + export function addExcludeFromIndexes( + excludeFromIndexes: string[] | undefined, + entityProto: EntityProto, + ): EntityProto { + if (excludeFromIndexes && excludeFromIndexes.length > 0) { + excludeFromIndexes.forEach((excludePath: string) => { + excludePathFromEntity(entityProto, excludePath); + }); + } + + return entityProto; + + function excludePathFromEntity(entity: EntityProto, path: string) { + if (!entity) return; + + const arrayIndex = path.indexOf('[]'); + const entityIndex = path.indexOf('.'); + const wildcardIndex = path.indexOf('.*'); + + const hasArrayPath = arrayIndex > -1; + const hasEntityPath = entityIndex > -1; + const hasWildCard = wildcardIndex > -1; + + if (!hasArrayPath && !hasEntityPath) { + // This is the path end node. Traversal ends here in either case. + if (entity.properties) { + if ( + entity.properties[path] && + // array properties should be excluded with [] syntax: + !entity.properties[path].arrayValue + ) { + // This is the property to exclude! + entity.properties[path].excludeFromIndexes = true; + } + } else if (!path) { + // This is a primitive or entity root that should be excluded. + entity.excludeFromIndexes = true; + } + return; + } + + let delimiterIndex; + if (hasArrayPath && hasEntityPath) { + delimiterIndex = Math.min(arrayIndex, entityIndex); + } else { + delimiterIndex = Math.max(arrayIndex, entityIndex); + } + + const firstPathPartIsArray = delimiterIndex === arrayIndex; + const firstPathPartIsEntity = delimiterIndex === entityIndex; + + const delimiter = firstPathPartIsArray ? '[]' : '.'; + const splitPath = path.split(delimiter); + const firstPathPart = splitPath.shift()!; + const remainderPath = splitPath.join(delimiter).replace(/^(\.|\[\])/, ''); + + if ( + !(entity.properties && entity.properties[firstPathPart]) && + !hasWildCard + ) { + // Either a primitive or an entity for which this path doesn't apply. + return; + } + + const isFirstPathPartDefined = + entity.properties![firstPathPart] !== undefined; + if ( + firstPathPartIsArray && + isFirstPathPartDefined && + // check also if the property in question is actually an array value. + entity.properties![firstPathPart].arrayValue && + // check if wildcard is not applied + !hasWildCard + ) { + const array = entity.properties![firstPathPart].arrayValue; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + array.values.forEach((value: any) => { + if (remainderPath === '') { + // We want to exclude *this* array property, which is + // equivalent with excluding all its values + // (including entity values at their roots): + excludePathFromEntity( + value, + remainderPath, // === '' + ); + } else { + // Path traversal continues at value.entityValue, + // if it is an entity, or must end at value. + excludePathFromEntity( + value.entityValue || value, + remainderPath, // !== '' + ); + } + }); + } else if ( + firstPathPartIsArray && + hasWildCard && + remainderPath === '*' && + isFirstPathPartDefined + ) { + const array = entity.properties![firstPathPart].arrayValue; + if (!array) return; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + array.values.forEach((value: any) => { + if (value.entityValue) { + excludePathFromEntity(value.entityValue, '.*'); + } else { + excludePathFromEntity(value, ''); + } + }); + } else if (firstPathPartIsEntity) { + if (firstPathPart === '') { + Object.keys(entity.properties!).forEach(path => { + const newPath = entity.properties![path].arrayValue + ? path + '[].*' + : path + '.*'; + excludePathFromEntity(entity, newPath); + }); + } else { + if (hasWildCard && remainderPath === '*' && isFirstPathPartDefined) { + const parentEntity = entity.properties![firstPathPart].entityValue; + + if (parentEntity) { + Object.keys(parentEntity.properties).forEach(path => { + const newPath = parentEntity.properties[path].arrayValue + ? path + '[].*' + : path + '.*'; + excludePathFromEntity(parentEntity, newPath); + }); + } else { + excludePathFromEntity(entity, firstPathPart); + } + } else if (isFirstPathPartDefined) { + const parentEntity = entity.properties![firstPathPart].entityValue; + excludePathFromEntity(parentEntity, remainderPath); + } + } + } + } + } + + /** + * Convert an API response array to a qualified Key and data object. + * + * @private + * @param {object[]} results The response array. + * @param {object} results.entity An entity object. + * @param {object} results.entity.key The entity's key. + * @param {boolean | IntegerTypeCastOptions} [wrapNumbers=false] Wrap values of integerValue type in + * {@link Datastore#Int} objects. + * If a `boolean`, this will wrap values in {@link Datastore#Int} objects. + * If an `object`, this will return a value returned by + * `wrapNumbers.integerTypeCastFunction`. + * Please see {@link IntegerTypeCastOptions} for options descriptions. + * + * @example + * ``` + * request_('runQuery', {}, (err, response) => { + * const entityObjects = formatArray(response.batch.entityResults); + * // { + * // key: {}, + * // data: { + * // fieldName: 'value' + * // } + * // } + * // + * }); + * ``` + */ + export function formatArray( + results: ResponseResult[], + wrapNumbers?: boolean | IntegerTypeCastOptions, + ) { + return results.map(result => { + const ent = entity.entityFromEntityProto(result.entity!, wrapNumbers); + ent[entity.KEY_SYMBOL] = entity.keyFromKeyProto(result.entity!.key!); + return ent; + }); + } + + /** + * Find the properties which value size is large than 1500 bytes, + * with excludeLargeProperties enabled, automatically exclude properties from indexing. + * This will allow storing string values larger than 1500 bytes + * + * @param entities Datastore key object(s). + * @param path namespace of provided entity properties + * @param properties properties which value size is large than 1500 bytes + */ + export function findLargeProperties_( + entities: Entities, + path: string, + properties: string[] = [], + ) { + const MAX_DATASTORE_VALUE_LENGTH = 1500; + if (Array.isArray(entities)) { + for (const entry of entities) { + findLargeProperties_(entry, path.concat('[]'), properties); + } + } else if (is.object(entities)) { + const keys = Object.keys(entities); + for (const key of keys) { + findLargeProperties_( + entities[key], + path.concat(`${path ? '.' : ''}${key}`), + properties, + ); + } + } else if ( + is.string(entities) && + Buffer.from(entities).length > MAX_DATASTORE_VALUE_LENGTH + ) { + if (properties.indexOf(path) < 0) { + properties.push(path); + } + } + return properties; + } + + /** + * Check if a key is complete. + * + * @private + * @param {Key} key The Key object. + * @returns {boolean} + * + * @example + * ``` + * isKeyComplete(new Key(['Company', 'Google'])); // true + * isKeyComplete(new Key('Company')); // false + * ``` + */ + export function isKeyComplete(key: Key) { + const lastPathElement = entity.keyToKeyProto(key).path!.pop()!; + return !!(lastPathElement.id || lastPathElement.name); + } + + /** + * Convert a key protocol object to a Key object. + * + * @private + * @param {object} keyProto The key protocol object to convert. + * @returns {Key} + * + * @example + * ``` + * const key = keyFromKeyProto({ + * partitionId: { + * projectId: 'project-id', + * namespaceId: '' + * }, + * path: [ + * { + * kind: 'Kind', + * id: '4790047639339008' + * } + * ] + * }); + * ``` + */ + export function keyFromKeyProto(keyProto: KeyProto): Key { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const keyOptions: any = { + path: [], + }; + + if (keyProto.partitionId && keyProto.partitionId.namespaceId) { + keyOptions.namespace = keyProto.partitionId.namespaceId; + } + + keyProto.path!.forEach((path, index) => { + keyOptions.path.push(path.kind); + + let id = path[path.idType!]; + + if (path.idType === 'id') { + id = new entity.Int(id); + } + + if (is.defined(id)) { + keyOptions.path.push(id); + } else if (index < keyProto.path!.length - 1) { + throw new InvalidKeyError({ + code: 'MISSING_ANCESTOR_ID', + }); + } + }); + + return new entity.Key(keyOptions); + } + + /** + * Convert a Key object to a key protocol object. + * + * @private + * @param {Key} key The Key object to convert. + * @returns {object} + * + * @example + * ``` + * const keyProto = keyToKeyProto(new Key(['Company', 1])); + * // { + * // path: [ + * // { + * // kind: 'Company', + * // id: 1 + * // } + * // ] + * // } + * ``` + */ + export function keyToKeyProto(key: Key): KeyProto { + if (is.undefined(key.kind)) { + throw new InvalidKeyError({ + code: 'MISSING_KIND', + }); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const keyProto: KeyProto = { + path: [], + }; + + if (key.namespace) { + keyProto.partitionId = { + namespaceId: key.namespace, + }; + } + + let numKeysWalked = 0; + + // Reverse-iterate over the Key objects. + do { + if (numKeysWalked > 0 && is.undefined(key.id) && is.undefined(key.name)) { + // This isn't just an incomplete key. An ancestor key is incomplete. + throw new InvalidKeyError({ + code: 'MISSING_ANCESTOR_ID', + }); + } + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const pathElement: any = { + kind: key.kind, + }; + + if (is.defined(key.id)) { + pathElement.id = key.id; + } + + if (is.defined(key.name)) { + pathElement.name = key.name; + } + + keyProto.path!.unshift(pathElement); + } while ((key = key.parent!) && ++numKeysWalked); + + return keyProto; + } + + /** + * Convert a query object to a query protocol object. + * + * @private + * @param {object} q The query object to convert. + * @returns {object} + * + * @example + * ``` + * queryToQueryProto({ + * namespace: '', + * kinds: [ + * 'Kind' + * ], + * filters: [], + * orders: [], + * groupByVal: [], + * selectVal: [], + * startVal: null, + * endVal: null, + * limitVal: -1, + * offsetVal: -1 + * }); + * // { + * // projection: [], + * // kinds: [ + * // { + * // name: 'Kind' + * // } + * // ], + * // order: [], + * // groupBy: [] + * // } + * ``` + */ + export function queryToQueryProto(query: Query): QueryProto { + const SIGN_TO_ORDER = { + '-': 'DESCENDING', + '+': 'ASCENDING', + }; + + const queryProto: QueryProto = { + distinctOn: query.groupByVal.map(groupBy => { + return { + name: groupBy, + }; + }), + + kind: query.kinds.map(kind => { + return { + name: kind, + }; + }), + + order: query.orders.map(order => { + return { + property: { + name: order.name, + }, + direction: SIGN_TO_ORDER[order.sign], + }; + }), + + projection: query.selectVal.map(select => { + return { + property: { + name: select, + }, + }; + }), + }; + + if (query.endVal) { + queryProto.endCursor = query.endVal; + } + + if (query.limitVal > 0) { + queryProto.limit = { + value: query.limitVal, + }; + } + + if (query.offsetVal > 0) { + queryProto.offset = query.offsetVal; + } + + if (query.startVal) { + queryProto.startCursor = query.startVal; + } + + // Check to see if there is at least one type of legacy filter or new filter. + if (query.filters.length > 0 || query.entityFilters.length > 0) { + // Convert all legacy filters into new property filter objects + const filters = query.filters.map( + filter => new PropertyFilter(filter.name, filter.op, filter.val), + ); + const entityFilters = query.entityFilters; + const allFilters = entityFilters.concat(filters); + /* + To be consistent with prior implementation, apply an AND composite filter + to the collection of Filter objects. Then, set the filter property as before + to the output of the toProto method. + */ + queryProto.filter = and(allFilters).toProto(); + } + + return queryProto; + } + + /** + * URL safe key encoding and decoding helper utility. + * + * This is intended to work with the "legacy" representation of a + * datastore "Key" used within Google App Engine (a so-called "Reference"). + * + * @private + * @class + */ + export class URLSafeKey { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + protos: any; + + constructor() { + this.protos = this.loadProtos_(); + } + + /** + * Load AppEngine protobuf file. + * + * @private + */ + loadProtos_() { + const root = new Protobuf.Root(); + const loadedRoot = root.loadSync( + path.join(__dirname, '..', 'protos', 'app_engine_key.proto'), + ); + loadedRoot.resolveAll(); + return loadedRoot.nested; + } + + /** + * Convert key to url safe base64 encoded string. + * + * @private + * @param {string} projectId Project Id. + * @param {entity.Key} key Entity key object. + * @param {string} locationPrefix Optional . + * The location prefix of an App Engine project ID. + * Often this value is 's~', but may also be 'e~', or other location prefixes + * currently unknown. + * @returns {string} base64 endocded urlsafe key. + */ + + legacyEncode( + projectId: string, + key: entity.Key, + locationPrefix?: string, + ): string { + const elements: {}[] = []; + let currentKey = key; + + do { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const element: any = { + type: currentKey.kind, + }; + + if (is.defined(currentKey.id)) { + element.id = currentKey.id; + } + + if (is.defined(currentKey.name)) { + element.name = currentKey.name; + } + + elements.unshift(element); + currentKey = currentKey.parent!; + } while (currentKey); + + if (locationPrefix) { + projectId = `${locationPrefix}${projectId}`; + } + + const reference = { + app: projectId, + namespace: key.namespace, + path: {element: elements}, + }; + + const buffer = this.protos.Reference.encode(reference).finish(); + return this.convertToBase64_(buffer); + } + + /** + * Helper to convert URL safe key string to entity key object + * + * This is intended to work with the "legacy" representation of a + * datastore "Key" used within Google App Engine (a so-called "Reference"). + * + * @private + * @param {entity.Key} key Entity key object. + * @param {string} locationPrefix Optional . + * The location prefix of an App Engine project ID. + * Often this value is 's~', but may also be 'e~', or other location prefixes + * currently unknown. + * @returns {string} Created urlsafe key. + */ + + legacyDecode(key: string): entity.Key { + const buffer = this.convertToBuffer_(key); + const message = this.protos.Reference.decode(buffer); + const reference = this.protos.Reference.toObject(message, { + longs: String, + }); + const pathElements: PathType[] = []; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + reference.path.element.forEach((element: any) => { + pathElements.push(element.type); + + if (is.defined(element.name)) { + pathElements.push(element.name); + } + + if (is.defined(element.id)) { + pathElements.push(new entity.Int(element.id as number)); + } + }); + + const keyOptions: entity.KeyOptions = { + path: pathElements, + }; + + if (!is.empty(reference.namespace)) { + keyOptions.namespace = reference.namespace; + } + + return new entity.Key(keyOptions); + } + + /** + * Convert buffer to base64 encoding. + * + * @private + * @param {Buffer} buffer The buffer to convert + * @returns {string} Base64 encoded string. + */ + convertToBase64_(buffer: Buffer): string { + return buffer + .toString('base64') + .replace(/\+/g, '-') + .replace(/\//g, '_') + .replace(/=+$/, ''); + } + + /** + * Rebuild base64 from encoded url safe string and convert to buffer. + * + * @private + * @param {string} val Encoded url safe string. + * @returns {string} Base64 encoded string. + */ + convertToBuffer_(val: string): Buffer { + val = val.replace(/-/g, '+').replace(/_/g, '/'); + val += '='.repeat(val.length % 4); + + return Buffer.from(val, 'base64'); + } + } +} + +export interface ValueProto { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [index: string]: any; + valueType?: string; + values?: ValueProto[]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + value?: any; + propertyName?: string; +} + +export interface EntityProto { + key?: KeyProto | null; + properties?: {[k: string]: ValueProto}; + excludeFromIndexes?: boolean; +} + +/* + * This is the interface the user would provide transform operations in before + * they are converted to the google.datastore.v1.IPropertyTransform + * interface. + * + */ +export type PropertyTransform = { + property: string; + setToServerValue: boolean; + increment: any; + maximum: any; + minimum: any; + appendMissingElements: any[]; + removeAllFromArray: any[]; +}; + +interface EntityWithTransforms { + transforms?: PropertyTransform[]; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export type Entity = any & EntityWithTransforms; +export type Entities = Entity | Entity[]; + +interface KeyProtoPathElement extends google.datastore.v1.Key.IPathElement { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [index: string]: any; + idType?: string; +} + +export interface KeyProto { + partitionId?: google.datastore.v1.IPartitionId | null; + path?: KeyProtoPathElement[] | null; +} + +export interface ResponseResult { + entity: EntityProto; +} + +export interface EntityObject { + data: {[k: string]: Entity}; + excludeFromIndexes?: string[]; +} + +export interface Json { + [field: string]: string; +} diff --git a/handwritten/nodejs-datastore/src/filter.ts b/handwritten/nodejs-datastore/src/filter.ts new file mode 100644 index 00000000000..f59ba2c6e69 --- /dev/null +++ b/handwritten/nodejs-datastore/src/filter.ts @@ -0,0 +1,166 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import {Operator, Filter as IFilter} from './query'; +import {entity} from './entity'; +import Key = entity.Key; + +const OP_TO_OPERATOR = new Map([ + ['=', 'EQUAL'], + ['>', 'GREATER_THAN'], + ['>=', 'GREATER_THAN_OR_EQUAL'], + ['<', 'LESS_THAN'], + ['<=', 'LESS_THAN_OR_EQUAL'], + ['HAS_ANCESTOR', 'HAS_ANCESTOR'], + ['!=', 'NOT_EQUAL'], + ['IN', 'IN'], + ['NOT_IN', 'NOT_IN'], +]); + +enum CompositeOperator { + AND = 'AND', + OR = 'OR', +} + +/** + * And filters are composed of many other filters and when they are applied + * then query results are only returned when they pass through all these other + * filters. + * + * @param {EntityFilter[]} filters The list of filters that make up the AND filter. + * @returns {CompositeFilter} A composite AND filter. + * + */ +export function and(filters: EntityFilter[]): CompositeFilter { + return new CompositeFilter(filters, CompositeOperator.AND); +} + +/** + * Or filters are composed of many other filters and when they are applied + * then query results are returned when they pass through any of these other + * filters. + * + * @param {EntityFilter[]} filters The list of filters that make up the OR filter. + * @returns {CompositeFilter} A composite OR filter. + * + */ +export function or(filters: EntityFilter[]): CompositeFilter { + return new CompositeFilter(filters, CompositeOperator.OR); +} + +/** + * A Filter is a class that contains data for a filter that can be translated + * into a proto when needed. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#filters| Filters Reference} + * + */ +export abstract class EntityFilter { + /** + * Gets the proto for the filter. + * + */ + // eslint-disable-next-line + abstract toProto(): any; +} + +export type AllowedFilterValueType = T extends '__key__' + ? Key | Key[] + : unknown; + +/** + * A PropertyFilter is a filter that gets applied to a query directly. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#property_filters| Property filters Reference} + * + * @class + */ +export class PropertyFilter + extends EntityFilter + implements IFilter +{ + /** + * Build a Property Filter object. + * + * @param {string} Property The property name that the filter will be applied to. + * @param {Operator} operator The comparison operator that the filter applies. + * @param {any} val The value that the filter compares the property to. + */ + constructor( + public name: T, + public op: Operator, + public val: AllowedFilterValueType, + ) { + super(); + } + + /** + * Gets the proto for the filter. + * + */ + // eslint-disable-next-line + toProto(): any { + return { + propertyFilter: { + property: { + name: this.name, + }, + op: OP_TO_OPERATOR.get(this.op), + value: entity.encodeValue(this.val, this.name), + }, + }; + } +} + +/** + * A CompositeFilter is a filter that combines other filters and applies that + * combination to a query. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#composite_filters| Composite filters Reference} + * + * @class + */ +class CompositeFilter extends EntityFilter { + filters: EntityFilter[]; + op: string; + + /** + * Build a Composite Filter object. + * + * @param {EntityFilter[]} filters The filters that make up the composite filter. + */ + constructor(filters: EntityFilter[], op: CompositeOperator) { + super(); + this.filters = filters; + this.op = op; + } + + /** + * Gets the proto for the filter. + * + */ + // eslint-disable-next-line + toProto(): any { + return { + compositeFilter: { + filters: this.filters.map(filter => filter.toProto()), + op: this.op, + }, + }; + } +} + +export function isFilter(filter: any): filter is EntityFilter { + return filter instanceof EntityFilter; +} diff --git a/handwritten/nodejs-datastore/src/index-class.ts b/handwritten/nodejs-datastore/src/index-class.ts new file mode 100644 index 00000000000..49027c9907d --- /dev/null +++ b/handwritten/nodejs-datastore/src/index-class.ts @@ -0,0 +1,160 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import {CallOptions, ServiceError} from 'google-gax'; +import {promisifyAll} from '@google-cloud/promisify'; + +import {Datastore} from './'; +import {google} from '../protos/protos'; + +export interface GenericIndexCallback { + ( + err?: ServiceError | null, + index?: Index | null, + apiResponse?: T | null, + ): void; +} + +export type GetIndexCallback = GenericIndexCallback; +export type GetIndexResponse = [Index, IIndex]; + +export type IndexGetMetadataCallback = ( + err?: ServiceError | null, + metadata?: IIndex | null, +) => void; +export type IndexGetMetadataResponse = [IIndex]; + +export interface GetIndexesOptions { + filter?: string; + gaxOptions?: CallOptions; + pageSize?: number; + pageToken?: string; + autoPaginate?: boolean; +} +export type GetIndexesResponse = [ + Index[], + GetIndexesOptions, + google.datastore.admin.v1.IListIndexesResponse, +]; +export type GetIndexesCallback = ( + err?: ServiceError | null, + indexes?: Index[], + nextQuery?: GetIndexesOptions, + apiResponse?: google.datastore.admin.v1.IListIndexesResponse, +) => void; + +export type IIndex = google.datastore.admin.v1.IIndex; + +/** + * @class + * @param {Datastore} datastore The parent instance of this index. + * @param {string} id The index name or id. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const index = datastore.index('my-index'); + * ``` + */ +export class Index { + datastore: Datastore; + id: string; + metadata?: IIndex; + + constructor(datastore: Datastore, id: string) { + this.datastore = datastore; + this.id = id.split('/').pop()!; + } + + /** + * Get an index if it exists. + * + * @param {object} [gaxOptions] Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/CallSettings.html. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request. + * @param {Index} callback.index The Index instance. + * @param {object} callback.apiResponse The full API response. + */ + get(gaxOptions?: CallOptions): Promise; + get(callback: GetIndexCallback): void; + get(gaxOptions: CallOptions, callback: GetIndexCallback): void; + get( + gaxOptionsOrCallback?: CallOptions | GetIndexCallback, + cb?: GetIndexCallback, + ): void | Promise { + const gaxOpts = + typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; + const callback = + typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb!; + + this.getMetadata(gaxOpts, (err, metadata) => { + callback(err, err ? null : this, metadata); + }); + } + + /** + * Get the metadata of this index. + * + * @param {object} [gaxOptions] Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/CallSettings.html. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request. + * @param {object} callback.metadata The metadata. + */ + getMetadata(gaxOptions?: CallOptions): Promise; + getMetadata(callback: IndexGetMetadataCallback): void; + getMetadata( + gaxOptions: CallOptions, + callback: IndexGetMetadataCallback, + ): void; + getMetadata( + gaxOptionsOrCallback?: CallOptions | IndexGetMetadataCallback, + cb?: IndexGetMetadataCallback, + ): void | Promise { + const gaxOpts = + typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; + const callback = + typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb!; + + this.datastore.request_( + { + client: 'DatastoreAdminClient', + method: 'getIndex', + reqOpts: { + indexId: this.id, + }, + gaxOpts, + }, + (err, resp) => { + if (resp) { + this.metadata = resp; + } + callback(err as ServiceError, resp); + }, + ); + } + + // @TODO implement create() + // @TODO implement delete() + // @TODO implement exists() +} + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +promisifyAll(Index); diff --git a/handwritten/nodejs-datastore/src/index.ts b/handwritten/nodejs-datastore/src/index.ts new file mode 100644 index 00000000000..64f0fb9e10d --- /dev/null +++ b/handwritten/nodejs-datastore/src/index.ts @@ -0,0 +1,1950 @@ +/*! + * Copyright 2018 Google LLC. + * + * Licensed under the Apache License, Version 2.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. + */ + +/** + * @namespace google + */ +/** + * @namespace google.datastore.v1 + */ +/** + * @namespace google.protobuf + */ + +import arrify = require('arrify'); +import extend = require('extend'); +import { + GrpcClient, + ClientStub, + ChannelCredentials, + GoogleAuth, + GoogleAuthOptions, + CallOptions, + Operation, + ServiceError, +} from 'google-gax'; +import * as is from 'is'; +import {pipeline, Transform} from 'stream'; + +import { + entity, + Entities, + Entity, + EntityProto, + ValueProto, + PropertyTransform, +} from './entity'; +import {AggregateField} from './aggregate'; +import Key = entity.Key; +export {Entity, Key, AggregateField}; +import {PropertyFilter, and, or} from './filter'; +export {PropertyFilter, and, or}; +import { + GetIndexesCallback, + GetIndexesOptions, + GetIndexesResponse, + IIndex, + Index, +} from './index-class'; +import {Query} from './query'; +import { + DatastoreRequest, + CommitCallback, + CommitResponse, + PrepareEntityObjectResponse, + SaveCallback, + SaveResponse, + Mutation, + RequestOptions, +} from './request'; +import {Transaction} from './transaction'; +import {promisifyAll} from '@google-cloud/promisify'; +import {google} from '../protos/protos'; +import {AggregateQuery} from './aggregate'; +import {SaveEntity} from './interfaces/save'; +import {extendExcludeFromIndexes} from './utils/entity/extendExcludeFromIndexes'; +import {buildEntityProto} from './utils/entity/buildEntityProto'; +import IValue = google.datastore.v1.IValue; +import IEntity = google.datastore.v1.IEntity; +import ServerValue = google.datastore.v1.PropertyTransform.ServerValue; +import {buildPropertyTransforms} from './utils/entity/buildPropertyTransforms'; + +const {grpc} = new GrpcClient(); + +export type PathType = string | number | entity.Int; +export interface BooleanObject { + [key: string]: boolean; +} +export interface EntityProtoReduceAccumulator { + [key: string]: ValueProto; +} +export interface EntityProtoReduceData { + value: ValueProto; + excludeFromIndexes: ValueProto; + name: string | number; +} +export type UpdateCallback = CommitCallback; +export type UpdateResponse = CommitResponse; +export type UpsertCallback = CommitCallback; +export type UpsertResponse = CommitResponse; +export type InsertCallback = CommitCallback; +export type InsertResponse = CommitResponse; + +export interface LongRunningCallback { + ( + err: ServiceError | null, + operation?: Operation, + apiResponse?: google.longrunning.IOperation, + ): void; +} +export type LongRunningResponse = [Operation, google.longrunning.IOperation]; +export type Fallback = boolean | 'rest' | 'proto'; + +export interface ExportEntitiesConfig + extends Omit { + bucket?: string | {name: string}; + kinds?: string[]; + namespaces?: string[]; + gaxOptions?: CallOptions; +} + +export interface ImportEntitiesConfig + extends Omit { + file?: string | {bucket: {name: string}; name: string}; + kinds?: string[]; + namespaces?: string[]; + gaxOptions?: CallOptions; +} + +// Import the clients for each version supported by this package. +const gapic = Object.freeze({ + v1: require('./v1'), +}); + +const urlSafeKey = new entity.URLSafeKey(); + +/** + * Idiomatic class for interacting with Cloud Datastore. Uses the lower-level + * {@link DatastoreClient} class under the hood. + * + * In addition to the constructor options shown here, the {@link Datastore} + * class constructor accepts the same options accepted by + * {@link DatastoreClient}. + * + *

The Datastore Emulator

+ * + * Make sure you have the + * gcloud SDK installed, then run: + * + *
+ *   $ gcloud beta emulators datastore start --no-legacy
+ * 
+ * + * You will see the following printed: + * + *
+ *   [datastore] API endpoint: http://localhost:8005
+ *   [datastore] If you are using a library that supports the
+ *               DATASTORE_EMULATOR_HOST environment variable, run:
+ *   [datastore]
+ *   [datastore]   export DATASTORE_EMULATOR_HOST=localhost:8005
+ *   [datastore]
+ *   [datastore] Dev App Server is now running.
+ * 
+ * + * Set that environment variable and your localhost Datastore will + * automatically be used. You can also pass this address in manually with + * `apiEndpoint`. + * + * Additionally, `DATASTORE_PROJECT_ID` is recognized. If you have this set, + * you don't need to provide a `projectId`. + * + * + * See {@link https://cloud.google.com/datastore/docs/concepts/overview| Cloud Datastore Concepts Overview} + * + * @param {object} [options] Configuration options. + * @param {string} [options.apiEndpoint] Override the default API endpoint used + * to reach Datastore. This is useful for connecting to your local Datastore + * server (usually "http://localhost:8080"). + * @param {string} [options.namespace] Namespace to isolate transactions to. + * + * @example Import the client library + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * + * ``` + * @example Create a client that uses Application Default Credentials (ADC): + * ``` + * const datastore = new Datastore(); + * + * ``` + * @example Create a client with explicit credentials: + * ``` + * const datastore = new Datastore({ + * projectId: 'your-project-id', + * keyFilename: '/path/to/keyfile.json' + * }); + * + * ``` + * @example Retrieving Records + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * + * // Records, called "entities" in Datastore, are retrieved by using a key. The + * // key is more than a numeric identifier, it is a complex data structure that + * // can be used to model relationships. The simplest key has a string `kind` + * // value, and either a numeric `id` value, or a string `name` value. + * // + * // A single record can be retrieved with {@link Datastore#key} and + * // {@link Datastore#get}. + * //- + * const key = datastore.key(['Company', 'Google']); + * + * datastore.get(key, function(err, entity) { + * // entity = The record. + * // entity[datastore.KEY] = The key for this entity. + * }); + * + * //- + * //

Querying Records

+ * // + * // Create a query with {@link Datastore#createQuery}. + * //- + * const query = datastore.createQuery('Company'); + * + * //- + * // Multiple records can be found that match criteria with + * // {@link Query#filter}. + * //- + * query.filter('location', 'CA'); + * + * //- + * // Records can also be ordered with {@link Query#order}. + * //- + * query.order('name'); + * + * //- + * // The number of records returned can be specified with + * // {@link Query#limit}. + * //- + * query.limit(5); + * + * //- + * // Records' key structures can also be queried with + * // {@link Query#hasAncestor}. + * //- + * const ancestorKey = datastore.key(['ParentCompany', 'Alphabet']); + * + * query.hasAncestor(ancestorKey); + * + * //- + * // Run the query with {@link Datastore#runQuery}. + * //- + * datastore.runQuery(query, (err, entities) => { + * // entities = An array of records. + * + * // Access the Key object for an entity. + * const firstEntityKey = entities[0][datastore.KEY]; + * }); + * + * ``` + * @example Paginating Records + * ``` + * // Imagine building a website that allows a user to sift through hundreds of + * // their contacts. You'll likely want to only display a subset of these at + * // once, so you set a limit. + * //- + * const express = require('express'); + * const app = express(); + * + * const NUM_RESULTS_PER_PAGE = 15; + * + * app.get('/contacts', (req, res) => { + * const query = datastore.createQuery('Contacts') + * .limit(NUM_RESULTS_PER_PAGE); + * + * if (req.query.nextPageCursor) { + * query.start(req.query.nextPageCursor); + * } + * + * datastore.runQuery(query, (err, entities, info) => { + * if (err) { + * // Error handling omitted. + * return; + * } + * + * // Respond to the front end with the contacts and the cursoring token + * // from the query we just ran. + * const frontEndResponse = { + * contacts: entities + * }; + * + * // Check if more results may exist. + * if (info.moreResults !== datastore.NO_MORE_RESULTS) { + * frontEndResponse.nextPageCursor = info.endCursor; + * } + * + * res.render('contacts', frontEndResponse); + * }); + * }); + * + * ``` + * @example Creating Records + * ``` + * // New entities can be created and persisted with {@link Datastore#save}. + * // The entity must have a key to be saved. If you don't specify an + * // identifier for the key, one is generated for you. + * // + * // We will create a key with a `name` identifier, "Google". + * //- + * const key = datastore.key(['Company', 'Google']); + * + * const data = { + * name: 'Google', + * location: 'CA' + * }; + * + * datastore.save({ + * key: key, + * data: data + * }, (err) => { + * if (!err) { + * // Record saved successfully. + * } + * }); + * + * //- + * // We can verify the data was saved by using {@link Datastore#get}. + * //- + * datastore.get(key, (err, entity) => { + * // entity = { + * // name: 'Google', + * // location: 'CA' + * // } + * }); + * + * //- + * // If we want to update this record, we can modify the data object and re- + * // save it. + * //- + * data.symbol = 'GOOG'; + * + * datastore.save({ + * key: key, // defined above (datastore.key(['Company', 'Google'])) + * data: data + * }, (err, entity) => { + * if (!err) { + * // Record updated successfully. + * } + * }); + * + * ``` + * @example Deleting Records + * ``` + * // Entities can be removed from Datastore by passing the entity's key object + * // to {@link Datastore#delete}. + * //- + * const key = datastore.key(['Company', 'Google']); + * + * datastore.delete(key, (err) => { + * if (!err) { + * // Record deleted successfully. + * } + * }); + * + * ``` + * @example Transactions + * ``` + * // Complex logic can be wrapped in a transaction with + * // {@link Datastore#transaction}. All queries and updates run within + * // the transaction will be applied when the `done` function is called. + * //- + * const transaction = datastore.transaction(); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * const key = datastore.key(['Company', 'Google']); + * + * transaction.get(key, (err, entity) => { + * if (err) { + * // Error handling omitted. + * } + * + * entity.symbol = 'GOOG'; + * + * transaction.save(entity); + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * }); + * + * ``` + * @example Queries with Ancestors + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * + * const customerId1 = 2993844; + * const customerId2 = 4993882; + * const customerKey1 = datastore.key(['Customer', customerId1]); + * const customerKey2 = datastore.key(['Customer', customerId2]); + * const cookieKey1 = datastore.key(['Customer', customerId1, 'Cookie', + * 'cookie28839']); // child entity const cookieKey2 = + * datastore.key(['Customer', customerId1, 'Cookie', 'cookie78984']); // child + * entity const cookieKey3 = datastore.key(['Customer', customerId2, 'Cookie', + * 'cookie93911']); // child entity + * + * const entities = []; + * + * entities.push({ + * key: customerKey1, + * data: { + * name: 'Jane Doe', + * address: '4848 Liller' + * } + * }); + * + * entities.push({ + * key: customerKey2, + * data: { + * name: 'John Smith', + * address: '4848 Pine' + * } + * }); + * + * entities.push({ + * key: cookieKey1, + * data: { + * cookieVal: 'dj83kks88rkld' + * } + * }); + * + * entities.push({ + * key: cookieKey2, + * data: { + * cookieVal: 'sj843ka99s' + * } + * }); + * + * entities.push({ + * key: cookieKey3, + * data: { + * cookieVal: 'otk82k2kw' + * } + * }); + * + * datastore.upsert(entities); + * + * const query = datastore.createQuery().hasAncestor(customerKey1); + * + * datastore.runQuery(query, (err, entities) => { + * for (let entity of entities) { + * console.log(entity[datastore.KEY]); + * } + * }); + * + * const query2 = datastore.createQuery().hasAncestor(customerKey2); + * + * datastore.runQuery(query2, (err, entities) => { + * for (let entity of entities) { + * console.log(entity[datastore.KEY]); + * } + * }); + * + * datastore.runQuery(query2, (entities) => { + * console.log(entities); + * }); + * ``` + */ +class Datastore extends DatastoreRequest { + clients_: Map; + namespace?: string; + defaultBaseUrl_: string; + options: DatastoreOptions; + baseUrl_?: string; + port_?: number; + customEndpoint_?: boolean; + auth: GoogleAuth; + constructor(options?: DatastoreOptions) { + super(); + options = options || {}; + this.clients_ = new Map(); + this.datastore = this; + + /** + * @name Datastore#namespace + * @type {string} + */ + this.namespace = options.namespace; + + options.projectId = options.projectId || process.env.DATASTORE_PROJECT_ID; + + this.defaultBaseUrl_ = 'datastore.googleapis.com'; + this.determineBaseUrl_(options.apiEndpoint); + + const scopes: string[] = Array.from( + new Set([ + ...gapic.v1.DatastoreClient.scopes, + ...gapic.v1.DatastoreAdminClient.scopes, + ]), + ); + + this.options = Object.assign( + { + libName: 'gccl', + libVersion: require('../../package.json').version, + scopes, + servicePath: this.baseUrl_, + port: typeof this.port_ === 'number' ? this.port_ : 443, + }, + options, + ); + const isUsingLocalhost = + this.baseUrl_ && + (this.baseUrl_.includes('localhost') || + this.baseUrl_.includes('127.0.0.1') || + this.baseUrl_.includes('::1')); + const isEmulatorVariableSet = process.env.DATASTORE_EMULATOR_HOST; + const isUsingEmulator = isUsingLocalhost || isEmulatorVariableSet; + if (this.customEndpoint_ && isUsingEmulator) { + this.options.sslCreds ??= grpc.credentials.createInsecure(); + } + + this.auth = new GoogleAuth(this.options); + } + + /** + * Create an aggregation query from a Query. + * + * @param {Query} query A Query object. + */ + createAggregationQuery(query: Query): AggregateQuery { + return new AggregateQuery(query); + } + + /** + * Export entities from this project to a Google Cloud Storage bucket. + * + * @param {ExportEntitiesConfig} config Configuration object. + * @param {string | Bucket} config.bucket The `gs://bucket` path or a + * @google-cloud/storage Bucket object. + * @param {string[]} [config.kinds] The kinds to include in this import. + * @param {string[]} [config.namespaces] The namespace IDs to include in this + * import. + * @param {object} [config.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request. + * @param {Operation} callback.operation An operation object that can be used + * to check the status of the request. + */ + export(config: ExportEntitiesConfig): Promise; + export(config: ExportEntitiesConfig, callback: LongRunningCallback): void; + export( + config: ExportEntitiesConfig, + callback?: LongRunningCallback, + ): void | Promise { + const reqOpts: ExportEntitiesConfig = { + entityFilter: {}, + ...config, + }; + + if (reqOpts.bucket && reqOpts.outputUrlPrefix) { + throw new Error('Both `bucket` and `outputUrlPrefix` were provided.'); + } + + if (!reqOpts.outputUrlPrefix) { + if (typeof config.bucket === 'string') { + reqOpts.outputUrlPrefix = `gs://${config.bucket.replace('gs://', '')}`; + } else if (typeof config.bucket === 'object') { + reqOpts.outputUrlPrefix = `gs://${config.bucket.name}`; + } else { + throw new Error('A Bucket object or URL must be provided.'); + } + } + + if (reqOpts.kinds) { + if (typeof config.entityFilter === 'object') { + throw new Error('Both `entityFilter` and `kinds` were provided.'); + } + reqOpts.entityFilter!.kinds = reqOpts.kinds; + } + + if (reqOpts.namespaces) { + if (typeof config.entityFilter === 'object') { + throw new Error('Both `entityFilter` and `namespaces` were provided.'); + } + reqOpts.entityFilter!.namespaceIds = reqOpts.namespaces; + } + + delete reqOpts.bucket; + delete reqOpts.gaxOptions; + delete reqOpts.kinds; + delete reqOpts.namespaces; + + this.request_( + { + client: 'DatastoreAdminClient', + method: 'exportEntities', + reqOpts: reqOpts as RequestOptions, + gaxOpts: config.gaxOptions, + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + callback as any, + ); + } + + /** + * Get all of the indexes in this project. + * + * @param {GetIndexesOptions | GetIndexesCallback} [optionsOrCallback] + * @param {object} [options.gaxOptions] Request configuration options, + * outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {GetIndexesResponse} [callback] The callback function. + * @param {?error} callback.error An error returned while making this request. + * @param {Index[]} callback.indexes All matching Index instances. + * @param {object} callback.apiResponse The full API response. + * @return {void | Promise} + */ + getIndexes(options?: GetIndexesOptions): Promise; + getIndexes(options: GetIndexesOptions, callback: GetIndexesCallback): void; + getIndexes(callback: GetIndexesCallback): void; + getIndexes( + optionsOrCallback?: GetIndexesOptions | GetIndexesCallback, + cb?: GetIndexesCallback, + ): void | Promise { + let options = + typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + + options = extend(true, {}, options); + + const gaxOpts = options.gaxOptions || {}; + + const reqOpts = { + pageSize: (gaxOpts as GetIndexesOptions).pageSize, + pageToken: (gaxOpts as GetIndexesOptions).pageToken, + ...options, + }; + + delete (gaxOpts as GetIndexesOptions).pageSize; + delete (gaxOpts as GetIndexesOptions).pageToken; + delete (reqOpts as CallOptions).autoPaginate; + delete (reqOpts as GetIndexesOptions).gaxOptions; + + if ( + typeof options.autoPaginate === 'boolean' && + typeof gaxOpts.autoPaginate === 'undefined' + ) { + gaxOpts.autoPaginate = options.autoPaginate; + } + + this.request_( + { + client: 'DatastoreAdminClient', + method: 'listIndexes', + reqOpts, + gaxOpts, + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (err, ...resp: any[]) => { + let indexes: Index[] = []; + + if (resp[0]) { + indexes = resp[0].map((index: IIndex) => { + const indexInstance = this.index(index.indexId!); + indexInstance.metadata = index; + return indexInstance; + }); + } + + const nextQuery = resp[1]! ? Object.assign(options, resp[1]) : null; + const apiResp: google.datastore.admin.v1.IListIndexesResponse = resp[2]; + + callback(err as ServiceError, indexes, nextQuery, apiResp); + }, + ); + } + + /** + * Get all of the indexes in this project as a readable object stream. + * + * @param {GetIndexesOptions} [options] Configuration object. See + * {@link Datastore#getIndexes} for a complete list of options. + * @returns {ReadableStream} + */ + getIndexesStream(options?: GetIndexesOptions): NodeJS.ReadableStream { + const {gaxOptions, ...reqOpts} = options || {}; + return pipeline( + this.requestStream_({ + client: 'DatastoreAdminClient', + method: 'listIndexesStream', + reqOpts, + gaxOpts: gaxOptions, + }), + new Transform({ + objectMode: true, + transform: (index: IIndex, enc: string, next: Function) => { + const indexInstance = this.index(index.indexId!); + indexInstance.metadata = index; + next(null, indexInstance); + }, + }), + () => {}, + ); + } + + /** + * Gets the database id that all requests will be run against. + * + * @returns {string} The database id that the current client is set to that + * requests will run against. + */ + getDatabaseId(): string | undefined { + return this.options.databaseId; + } + + getProjectId(): Promise { + return this.auth.getProjectId(); + } + + /** + * Import entities into this project from a remote file. + * + * @param {ImportEntitiesConfig} config Configuration object. + * @param {string | File} config.file The `gs://bucket/file` path or a + * @google-cloud/storage File object. + * @param {string[]} [config.kinds] The kinds to include in this import. + * @param {string[]} [config.namespaces] The namespace IDs to include in this + * import. + * @param {object} [config.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request. + * @param {Operation} callback.operation An operation object that can be used + * to check the status of the request. + */ + import(config: ImportEntitiesConfig): Promise; + import(config: ImportEntitiesConfig, callback: LongRunningCallback): void; + import( + config: ImportEntitiesConfig, + callback?: LongRunningCallback, + ): void | Promise { + const reqOpts: ImportEntitiesConfig = { + entityFilter: {}, + ...config, + }; + + if (config.file && config.inputUrl) { + throw new Error('Both `file` and `inputUrl` were provided.'); + } + + if (!reqOpts.inputUrl) { + if (typeof config.file === 'string') { + reqOpts.inputUrl = `gs://${config.file.replace('gs://', '')}`; + } else if (typeof config.file === 'object') { + reqOpts.inputUrl = `gs://${config.file.bucket.name}/${config.file.name}`; + } else { + throw new Error('An input URL must be provided.'); + } + } + + if (reqOpts.kinds) { + if (typeof config.entityFilter === 'object') { + throw new Error('Both `entityFilter` and `kinds` were provided.'); + } + reqOpts.entityFilter!.kinds = reqOpts.kinds; + } + + if (reqOpts.namespaces) { + if (typeof config.entityFilter === 'object') { + throw new Error('Both `entityFilter` and `namespaces` were provided.'); + } + reqOpts.entityFilter!.namespaceIds = reqOpts.namespaces; + } + + delete reqOpts.file; + delete reqOpts.gaxOptions; + delete reqOpts.kinds; + delete reqOpts.namespaces; + + this.request_( + { + client: 'DatastoreAdminClient', + method: 'importEntities', + reqOpts: reqOpts as RequestOptions, + gaxOpts: config.gaxOptions, + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + callback as any, + ); + } + + /** + * Get a reference to an Index. + * + * @param {string} id The index name or id. + * @returns {Index} + */ + index(id: string): Index { + return new Index(this, id); + } + + /** + * Maps to {@link https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/datastore#_google_cloud_datastore_Datastore_save_member_1_|Datastore#save}, forcing the method to be `insert`. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entities.data Data to save with the provided key. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {object} callback.apiResponse The full API response. + */ + insert(entities: Entities): Promise; + insert(entities: Entities, callback: InsertCallback): void; + insert( + entities: Entities, + callback?: InsertCallback, + ): void | Promise { + entities = arrify(entities) + .map(DatastoreRequest.prepareEntityObject_) + .map((x: PrepareEntityObjectResponse) => { + x.method = 'insert'; + return x; + }); + + this.save(entities, callback!); + } + + /** + * Insert or update the specified object(s). If a key is incomplete, its + * associated object is inserted and the original Key object is updated to + * contain the generated ID. + * + * This method will determine the correct Datastore method to execute + * (`upsert`, `insert`, or `update`) by using the key(s) provided. For + * example, if you provide an incomplete key (one without an ID), the request + * will create a new entity and have its ID automatically assigned. If you + * provide a complete key, the entity will be updated with the data specified. + * + * By default, all properties are indexed. To prevent a property from being + * included in *all* indexes, you must supply an `excludeFromIndexes` array. + * + * To prevent large properties from being included in *all* indexes, you must supply + * `excludeLargeProperties: true`. + * See below for an example. + * + * @borrows {@link Transaction#save} as save + * + * @throws {Error} If an unrecognized method is provided. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the example below to + * see how to target properties at different levels of nesting within your + * @param {boolean} [entities.excludeLargeProperties] Automatically exclude + * large properties from indexing. It help in storing large values. + * @param {string} [entities.method] Explicit method to use, either 'insert', + * 'update', or 'upsert'. + * @param {object} entities.data Data to save with the provided key. + * entity. + * @param {object} [gaxOptions] Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {object} callback.apiResponse The full API response. + * + * @example + * ``` + * //- + * // Save a single entity. + * // + * // Notice that we are providing an incomplete key. After saving, the + * // original Key object used to save will be updated to contain the path + * // with its generated ID. + * //- + * const key = datastore.key('Company'); + * const entity = { + * key: key, + * data: { + * rating: '10' + * } + * }; + * + * datastore.save(entity, (err) => { + * console.log(key.path); // [ 'Company', 5669468231434240 ] + * console.log(key.namespace); // undefined + * }); + * + * //- + * // Save a single entity using a provided name instead of auto-generated ID. + * // + * // Here we are providing a key with name instead of an ID. After saving, + * // the original Key object used to save will be updated to contain the + * // path with the name instead of a generated ID. + * //- + * const key = datastore.key(['Company', 'donutshack']); + * const entity = { + * key: key, + * data: { + * name: 'DonutShack', + * rating: 8 + * } + * }; + * + * datastore.save(entity, (err) => { + * console.log(key.path); // ['Company', 'donutshack'] + * console.log(key.namespace); // undefined + * }); + * + * //- + * // Save a single entity with a provided namespace. Namespaces allow for + * // multitenancy. To read more about this, see + * // [the Datastore docs on key concepts](https://goo.gl/M1LUAu). + * // + * // Here we are providing a key with namespace. + * //- + * const key = datastore.key({ + * namespace: 'my-namespace', + * path: ['Company', 'donutshack'] + * }); + * + * const entity = { + * key: key, + * data: { + * name: 'DonutShack', + * rating: 8 + * } + * }; + * + * datastore.save(entity, (err) => { + * console.log(key.path); // ['Company', 'donutshack'] + * console.log(key.namespace); // 'my-namespace' + * }); + * + * //- + * // Save different types of data, including ints, doubles, dates, booleans, + * // blobs, and lists. + * // + * // Notice that we are providing an incomplete key. After saving, the + * // original Key object used to save will be updated to contain the path + * // with its generated ID. + * //- + * const key = datastore.key('Company'); + * const entity = { + * key: key, + * data: { + * name: 'DonutShack', + * rating: datastore.int(10), + * worth: datastore.double(123456.78), + * location: datastore.geoPoint({ + * latitude: 40.6894, + * longitude: -74.0447 + * }), + * numDonutsServed: 45, + * founded: new Date('Tue May 12 2015 15:30:00 GMT-0400 (EDT)'), + * isStartup: true, + * donutEmoji: Buffer.from('\uD83C\uDF69'), + * keywords: [ + * 'donut', + * 'coffee', + * 'yum' + * ] + * } + * }; + * + * datastore.save(entity, (err, apiResponse) => {}); + * + * //- + * // Use an array, `excludeFromIndexes`, to exclude properties from indexing. + * // This will allow storing string values larger than 1500 bytes. + * //- + * const entity = { + * key: datastore.key('Company'), + * excludeFromIndexes: [ + * 'description', + * 'embeddedEntity.description', + * 'arrayValue[]', + * 'arrayValue[].description' + * ], + * data: { + * description: 'Long string (...)', + * embeddedEntity: { + * description: 'Long string (...)' + * }, + * arrayValue: [ + * 'Long string (...)', + * { + * description: 'Long string (...)' + * } + * ] + * } + * }; + * + * datastore.save(entity, (err, apiResponse) => {}); + * + * //- + * // Use boolean `excludeLargeProperties`, to auto exclude Large properties from indexing. + * // This will allow storing string values larger than 1500 bytes. + * //- + * const entity = { + * key: datastore.key('Company'), + * data: { + * description: 'Long string (...)', + * embeddedEntity: { + * description: 'Long string (...)' + * }, + * arrayValue: [ + * 'Long string (...)', + * { + * description: 'Long string (...)' + * } + * ] + * }, + * excludeLargeProperties: true + * }; + * + * datastore.save(entity, (err, apiResponse) => {}); + * + * //- + * // Save multiple entities at once. + * //- + * const companyKey = datastore.key(['Company', 123]); + * const productKey = datastore.key(['Product', 'Computer']); + * const entities = [ + * { + * key: companyKey, + * data: { + * HQ: 'Dallas, TX' + * } + * }, + * { + * key: productKey, + * data: { + * vendor: 'Dell' + * } + * } + * ]; + * + * datastore.save(entities, (err, apiResponse) => {}); + * + * //- + * // Explicitly attempt to 'insert' a specific entity. + * //- + * const userKey = datastore.key(['User', 'chilts']); + * const entity = { + * key: userKey, + * method: 'insert', + * data: { + * fullName: 'Andrew Chilton' + * } + * }; + * + * datastore.save(entity, (err, apiResponse) => {}); + * + * //- + * // Returns a Promise if callback is omitted. + * //- + * datastore.save(entity).then((data) => { + * const apiResponse = data[0]; + * }); + * ``` + */ + save(entities: Entities, gaxOptions?: CallOptions): Promise; + save( + entities: Entities, + gaxOptions: CallOptions, + callback: SaveCallback, + ): void; + save(entities: Entities, callback: SaveCallback): void; + save( + entities: Entities, + gaxOptionsOrCallback?: CallOptions | SaveCallback, + cb?: SaveCallback, + ): void | Promise { + entities = arrify(entities) as SaveEntity[]; + const gaxOptions = + typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; + const callback = + typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb!; + + const insertIndexes: BooleanObject = {}; + const mutations: google.datastore.v1.IMutation[] = []; + const methods: BooleanObject = { + insert: true, + update: true, + upsert: true, + }; + + // Iterate over the entity objects, build a proto from all keys and values, + // then place in the correct mutation array (insert, update, etc). + entities + .map(DatastoreRequest.prepareEntityObject_) + .forEach((entityObject: Entity, index: number) => { + const mutation: google.datastore.v1.IMutation = {}; + + let method = 'upsert'; + + if (entityObject.method) { + if (methods[entityObject.method]) { + method = entityObject.method; + } else { + throw new Error( + 'Method ' + entityObject.method + ' not recognized.', + ); + } + } + + if (!entity.isKeyComplete(entityObject.key)) { + insertIndexes[index] = true; + } + + extendExcludeFromIndexes(entityObject); + const entityProto = buildEntityProto(entityObject); + + entityProto.key = entity.keyToKeyProto(entityObject.key); + + mutation[method as 'upsert' | 'update' | 'insert' | 'delete'] = + entityProto as IEntity; + + // We built the entityProto, now we should add the data transforms: + if (entityObject.transforms) { + mutation.propertyTransforms = buildPropertyTransforms( + entityObject.transforms, + ); + } + mutations.push(mutation); + }); + + const reqOpts = { + mutations, + }; + + function onCommit( + err?: Error | null, + resp?: google.datastore.v1.ICommitResponse, + ) { + if (err || !resp) { + callback(err, resp); + return; + } + + arrify(resp.mutationResults).forEach((result, index) => { + if (!result.key) { + return; + } + if (insertIndexes[index]) { + const id = entity.keyFromKeyProto(result.key).id; + entities[index].key.id = id; + } + }); + + callback(null, resp); + } + + if (this.id) { + this.requests_.push(reqOpts); + this.requestCallbacks_.push(onCommit); + return; + } + + this.request_( + { + client: 'DatastoreClient', + method: 'commit', + reqOpts, + gaxOpts: gaxOptions, + }, + onCommit, + ); + } + + /** + * Maps to {@link https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/datastore#_google_cloud_datastore_Datastore_save_member_1_|Datastore#save}, forcing the method to be `update`. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entities.data Data to save with the provided key. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {object} callback.apiResponse The full API response. + */ + update(entities: Entities): Promise; + update(entities: Entities, callback: UpdateCallback): void; + update( + entities: Entities, + callback?: UpdateCallback, + ): void | Promise { + entities = arrify(entities) + .map(DatastoreRequest.prepareEntityObject_) + .map((x: PrepareEntityObjectResponse) => { + x.method = 'update'; + return x; + }); + + this.save(entities, callback!); + } + + /** + * Maps to {@link https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/datastore#_google_cloud_datastore_Datastore_save_member_1_|Datastore#save}, forcing the method to be `upsert`. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entities.data Data to save with the provided key. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {object} callback.apiResponse The full API response. + */ + upsert(entities: Entities): Promise; + upsert(entities: Entities, callback: UpsertCallback): void; + upsert( + entities: Entities, + callback?: UpsertCallback, + ): void | Promise { + entities = arrify(entities) + .map(DatastoreRequest.prepareEntityObject_) + .map((x: PrepareEntityObjectResponse) => { + x.method = 'upsert'; + return x; + }); + + this.save(entities, callback!); + } + + /** + * Helper function to get a Datastore Double object. + * + * @param {number} value The double value. + * @returns {object} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const threeDouble = datastore.double(3.0); + * ``` + */ + static double(value: number) { + return new entity.Double(value); + } + + /** + * Helper function to get a Datastore Double object. + * + * @param {number} value The double value. + * @returns {object} + */ + double(value: number) { + return Datastore.double(value); + } + + /** + * Helper function to check if something is a Datastore Double object. + * + * @param {*} value The double value. + * @returns {boolean} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * datastore.isDouble(0.42); // false + * datastore.isDouble(datastore.double(0.42)); // true + * ``` + */ + static isDouble(value?: {}) { + return entity.isDsDouble(value); + } + + /** + * Helper function to check if something is a Datastore Double object. + * + * @param {*} value The double value. + * @returns {boolean} + * + */ + isDouble(value?: {}) { + return Datastore.isDouble(value); + } + + /** + * Helper function to get a Datastore Geo Point object. + * + * @param {object} coordinates The coordinates value. + * @param {number} coordinates.latitude Latitudinal value. + * @param {number} coordinates.longitude Longitudinal value. + * @returns {object} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const coordinates = { + * latitude: 40.6894, + * longitude: -74.0447 + * }; + * + * const geoPoint = datastore.geoPoint(coordinates); + * + * //- + * // List all companies that are located at 40.123 latitude + * // and -74.0447 longitude. + * //- + * const query = datastore.createQuery('Company'); + * const companyQuery = query + * .filter('geoPoint.latitude', datastore.double(40.123)) + * .filter('geoPoint.longitude', datastore.double(-74.0447)); + * ``` + */ + static geoPoint(coordinates: entity.Coordinates) { + return new entity.GeoPoint(coordinates); + } + + /** + * Helper function to get a Datastore Geo Point object. + * + * @param {object} coordinates The coordinates value. + * @param {number} coordinates.latitude Latitudinal value. + * @param {number} coordinates.longitude Longitudinal value. + * @returns {object} + * + */ + geoPoint(coordinates: entity.Coordinates) { + return Datastore.geoPoint(coordinates); + } + + /** + * Helper function to check if something is a Datastore Geo Point object. + * + * @param {*} value The coordinates value. + * @returns {boolean} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const coordinates = { + * latitude: 0, + * longitude: 0 + * }; + * + * datastore.isGeoPoint(coordinates); // false + * datastore.isGeoPoint(datastore.geoPoint(coordinates)); // true + * ``` + */ + static isGeoPoint(value?: {}) { + return entity.isDsGeoPoint(value); + } + + /** + * Helper function to check if something is a Datastore Geo Point object. + * + * @param {*} value The coordinates value. + * @returns {boolean} + * + */ + isGeoPoint(value?: {}) { + return Datastore.isGeoPoint(value); + } + + /** + * Helper function to get a Datastore Integer object. + * + * This is also useful when using an ID outside the bounds of a JavaScript + * Number object. + * + * @param {number} value The integer value. + * @returns {object} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const sevenInteger = datastore.int(7); + * + * //- + * // Create an Int to support long Key IDs. + * //- + * const key = datastore.key([ + * 'Kind', + * datastore.int('100000000000001234') + * ]); + * ``` + */ + static int(value: number | string) { + return new entity.Int(value); + } + + /** + * Helper function to get a Datastore Integer object. + * + * This is also useful when using an ID outside the bounds of a JavaScript + * Number object. + * + * @param {number | int} value The integer value. + * @returns {object} + * + */ + int(value: number | string) { + return Datastore.int(value); + } + + /** + * Helper function to check if something is a Datastore Integer object. + * + * @param {*} value The value to check + * @returns {boolean} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * datastore.isInt(42); // false + * datastore.isInt(datastore.int(42)); // true + * ``` + */ + static isInt(value?: {}) { + return entity.isDsInt(value); + } + + /** + * Helper function to check if something is a Datastore Integer object. + * + * @param {*} value The value to check + * @returns {boolean} + * + */ + isInt(value?: {}) { + return Datastore.isInt(value); + } + + /** + * Access the Key from an Entity object. + * + * @name Datastore.KEY + * @type {symbol} + */ + /** + * Access the Key from an Entity object. + * + * @name Datastore#KEY + * @type {symbol} + */ + static KEY: typeof entity.KEY_SYMBOL = entity.KEY_SYMBOL; + KEY: typeof entity.KEY_SYMBOL = Datastore.KEY; + + /** + * This is one of three values which may be returned from + * {@link Datastore#runQuery}, {@link Transaction#runQuery}, and + * {@link Query#run} as `info.moreResults`. + * + * There *may* be more results after the specified end cursor. + * + * @type {string} + */ + static MORE_RESULTS_AFTER_CURSOR = 'MORE_RESULTS_AFTER_CURSOR'; + MORE_RESULTS_AFTER_CURSOR = Datastore.MORE_RESULTS_AFTER_CURSOR; + + /** + * This is one of three values which may be returned from + * {@link Datastore#runQuery}, {@link Transaction#runQuery}, and + * {@link Query#run} as `info.moreResults`. + * + * There *may* be more results after the specified limit. + * + * @type {string} + */ + static MORE_RESULTS_AFTER_LIMIT = 'MORE_RESULTS_AFTER_LIMIT'; + MORE_RESULTS_AFTER_LIMIT = Datastore.MORE_RESULTS_AFTER_LIMIT; + + /** + * This is one of three values which may be returned from + * {@link Datastore#runQuery}, {@link Transaction#runQuery}, and + * {@link Query#run} as `info.moreResults`. + * + * There are no more results left to query for. + * + * @type {string} + */ + static NO_MORE_RESULTS = 'NO_MORE_RESULTS'; + NO_MORE_RESULTS = Datastore.NO_MORE_RESULTS; + + /** + * Create a query for the specified kind. See {@link Query} for all + * of the available methods. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries| Datastore Queries} + * @see {@link Query} + * + * @param {string} [namespace] Namespace. + * @param {string} kind The kind to query. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const query = datastore.createQuery('Company'); + * ``` + */ + createQuery(kind?: string): Query; + createQuery(kind?: string[]): Query; + createQuery(namespace: string, kind: string): Query; + createQuery(namespace: string, kind: string[]): Query; + createQuery( + namespaceOrKind?: string | string[], + kind?: string | string[], + ): Query { + let namespace = namespaceOrKind as string; + if (!kind) { + kind = namespaceOrKind; + namespace = this.namespace!; + } + return new Query(this, namespace, arrify(kind) as string[]); + } + + /** + * Helper to create a Key object, scoped to the instance's namespace by + * default. + * + * You may also specify a configuration object to define a namespace and path. + * + * @param {object|string|array} [options] Key path. To specify or override a namespace, + * you must use an object here to explicitly state it. + * @param {string|array} [options.path] Key path. + * @param {string} [options.namespace] Optional namespace. + * @returns {Key} A newly created Key from the options given. + * + * @example + * ``` + * Create an incomplete key with a kind value of `Company`. + * Since no Id is supplied, Datastore will generate one on save. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key('Company'); + * + * ``` + * @example + * ``` + * Create a complete key with a kind value of `Company` and Id `123`. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key(['Company', 123]); + * + * ``` + * @example + * ``` + * If the ID integer is outside the bounds of a JavaScript Number + * object, create an Int. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key([ + * 'Company', + * datastore.int('100000000000001234') + * ]); + * + * ``` + * @example + * ``` + * Create a complete key with a kind value of `Company` and name `Google`. + * Because the supplied Id is a string, Datastore will prefix it with "name=". + * Had the supplied Id been numeric, Datastore would prefix it with the standard, "id=". + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key(['Company', 'Google']); + * + * ``` + * @example + * ``` + * Create a complete key from a provided namespace and path. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key({ + * namespace: 'My-NS', + * path: ['Company', 123] + * }); + * + * ``` + * @example + * ``` + * Create a complete key that specifies an ancestor. This will create a Team entity + * with a name of "Datastore", which belongs to the Company with the "name=Google" key. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key(['Company', 'Google', 'Team', 'Datastore']); + * + * ``` + * @example + * ``` + * Create a incomplete key that specifies an ancestor. This will create an Employee entity + * with an auto-generated Id, which belongs to the Company with the "name=Google" key. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key(['Company', 'Google', 'Employee']); + * ``` + */ + key(options: entity.KeyOptions): entity.Key; + key(path: PathType[]): entity.Key; + key(path: string): entity.Key; + key(options: string | entity.KeyOptions | PathType[]): entity.Key { + const keyOptions = is.object(options) + ? (options as entity.KeyOptions) + : { + namespace: this.namespace, + path: arrify(options) as PathType[], + }; + return new entity.Key(keyOptions); + } + + /** + * Helper function to check if something is a Datastore Key object. + * + * @param {*} value Value to compare property to. + * @returns {boolean} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * datastore.isKey({path: ['Company', 123]}); // false + * datastore.isKey(datastore.key(['Company', 123])); // true + * ``` + */ + static isKey(value?: {}) { + return entity.isDsKey(value); + } + isKey(value?: {}) { + return Datastore.isKey(value); + } + + /** + * Helper to create a URL safe key. + * + * This is intended to work with the "legacy" representation of a + * datastore "Key" used within Google App Engine (a so-called "Reference"). + * The returned string can be used as the "urlsafe" + * The base64 encoded values will have padding removed. + * + * + * @param {entity.Key} key Entity key object. + * @param {string} locationPrefix Optional . + * The location prefix of an App Engine project ID. + * Often this value is 's~', but may also be 'e~', or other location prefixes + * currently unknown. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {string} callback.urlSafeKey A Base64-encoded URL-safe key. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const key = datastore.key(['Company', 'Google']); + * + * datastore.keyToLegacyUrlSafe(key, (err, urlSafeKey) => { + * if (err) { + * // Error handling omitted. + * } + * console.log(urlSafeKey); + * }); + * + * //- + * // Create a complete URL-safe key using a location prefix. + * //- + * const locationPrefix = 's~'; + * + * datastore.keyToLegacyUrlSafe(key, locationPrefix, (err, urlSafeKey) => { + * if (err) { + * // Error handling omitted. + * } + * console.log(urlSafeKey); + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * datastore.keyToLegacyUrlSafe(key).then((data) => { + * const urlSafeKey = data[0]; + * console.log(urlSafeKey); + * }); + * ``` + */ + keyToLegacyUrlSafe(key: entity.Key, locationPrefix?: string): Promise; + keyToLegacyUrlSafe( + key: entity.Key, + callback: KeyToLegacyUrlSafeCallback, + ): void; + keyToLegacyUrlSafe( + key: entity.Key, + locationPrefix: string, + callback: KeyToLegacyUrlSafeCallback, + ): void; + keyToLegacyUrlSafe( + key: entity.Key, + locationPrefixOrCallback?: string | KeyToLegacyUrlSafeCallback, + callback?: KeyToLegacyUrlSafeCallback, + ): Promise | void { + const locationPrefix = + typeof locationPrefixOrCallback === 'string' + ? locationPrefixOrCallback + : ''; + callback = + typeof locationPrefixOrCallback === 'function' + ? locationPrefixOrCallback + : callback; + this.auth.getProjectId((err, projectId) => { + if (err) { + callback!(err); + return; + } + callback!(null, urlSafeKey.legacyEncode(projectId!, key, locationPrefix)); + }); + } + + /** + * Helper to convert URL safe key string to entity key object + * + * This is intended to work with the "legacy" representation of a + * datastore "Key" used within Google App Engine (a so-called "Reference"). + * + * @param {entity.Key} key Entity key object. + * @param {string} locationPrefix Optional . + * The location prefix of an App Engine project ID. + * Often this value is 's~', but may also be 'e~', or other location prefixes + * currently unknown. + * @returns {string} Created urlsafe key. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const urlSafeKey = 'ag9ncmFzcy1jbHVtcC00NzlyEwsSB0NvbXBhbnkiBkdvb2dsZQw'; + * + * datastore.keyFromLegacyUrlsafe(key); + * + * ``` + */ + keyFromLegacyUrlsafe(key: string): entity.Key { + return urlSafeKey.legacyDecode(key); + } + + /** + * Create a new Transaction object. + * + * @param {object} [options] Configuration object. + * @param {string} [options.id] The ID of a previously run transaction. + * @param {boolean} [options.readOnly=false] A read-only transaction cannot + * modify entities. + * @returns {Transaction} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * ``` + */ + transaction(options?: TransactionOptions) { + return new Transaction(this, options); + } + + /** + * Determine the appropriate endpoint to use for API requests. If not + * explicitly defined, check for the "DATASTORE_EMULATOR_HOST" environment + * variable, used to connect to a local Datastore server. + * + * @private + * + * @param {string} customApiEndpoint Custom API endpoint. + */ + determineBaseUrl_(customApiEndpoint?: string) { + let baseUrl = this.defaultBaseUrl_; + const leadingProtocol = new RegExp('^https*://'); + const trailingSlashes = new RegExp('/*$'); + const port = new RegExp(':(\\d+)'); + + if (customApiEndpoint) { + baseUrl = customApiEndpoint; + this.customEndpoint_ = true; + } else if (process.env.DATASTORE_EMULATOR_HOST) { + baseUrl = process.env.DATASTORE_EMULATOR_HOST; + this.customEndpoint_ = true; + } + + if (port.test(baseUrl)) { + this.port_ = Number(baseUrl.match(port)![1]); + } + + this.baseUrl_ = baseUrl + .replace(leadingProtocol, '') + .replace(port, '') + .replace(trailingSlashes, ''); + } + + /** + * {@link DatastoreRequest} class. + * + * @name Datastore.DatastoreRequest + * @see DatastoreRequest + * @type {constructor} + */ + DatastoreRequest = DatastoreRequest; + + /** + * {@link Query} class. + * + * @name Datastore.Query + * @see Query + * @type {constructor} + */ + Query = Query; + + /** + * {@link Transaction} class. + * + * @name Datastore.Transaction + * @see Transaction + * @type {constructor} + */ + Transaction = Transaction; +} + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +promisifyAll(Datastore, { + exclude: [ + 'createAggregationQuery', + 'double', + 'isDouble', + 'geoPoint', + 'getDatabaseId', + 'getProjectId', + 'isGeoPoint', + 'index', + 'int', + 'isInt', + 'createQuery', + 'key', + 'isKey', + 'keyFromLegacyUrlsafe', + 'transaction', + ], +}); + +export {Datastore}; + +/** + * The default export of the `@google-cloud/datastore` package is the + * {@link Datastore} class. + * + * See the {@link Datastore} class for client methods and configuration options. + * + * @module {Datastore} @google-cloud/datastore + * @alias nodejs-datastore + * + * @example Install the client library with npm: + * ``` + * npm install --save + * ``` + * @google-cloud/datastore + * + * @example Import the client library + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * + * ``` + * @example Create a client that uses Application Default Credentials (ADC): + * ``` + * const datastore = new Datastore(); + * + * ``` + * @example Create a client with explicit credentials: + * ``` + * const datastore = new Datastore({ projectId: + * 'your-project-id', keyFilename: '/path/to/keyfile.json' + * }); + * + * ``` + * @example include:samples/quickstart.js + * region_tag:datastore_quickstart + * Full quickstart example: + */ + +/** + * @name Datastore.v1 + * @see v1.DatastoreClient + * @type {object} + * @property {constructor} DatastoreClient + * Reference to {@link v1.DatastoreClient}. + */ + +/** + * @name module:@google-cloud/datastore.v1 + * @see v1.DatastoreClient + * @type {object} + * @property {constructor} DatastoreClient + * Reference to {@link v1.DatastoreClient}. + */ +module.exports.v1 = gapic.v1; + +export interface TransactionOptions { + id?: string; + readOnly?: boolean; +} + +export {Index, DatastoreRequest, Query, Transaction}; + +export interface DatastoreOptions extends GoogleAuthOptions { + namespace?: string; + apiEndpoint?: string; + sslCreds?: ChannelCredentials; + databaseId?: string; + fallback?: Fallback; +} + +export interface KeyToLegacyUrlSafeCallback { + (err?: Error | null, urlSafeKey?: string): void; +} +const v1 = gapic.v1; +export {v1}; + +export {DatastoreClient, DatastoreAdminClient} from './v1'; diff --git a/handwritten/nodejs-datastore/src/interfaces/save.ts b/handwritten/nodejs-datastore/src/interfaces/save.ts new file mode 100644 index 00000000000..5bbd974bbfb --- /dev/null +++ b/handwritten/nodejs-datastore/src/interfaces/save.ts @@ -0,0 +1,74 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {Entity, entity} from '../entity'; + +/* +Entity data passed into save in non array form will be of type SaveNonArrayData +and does not require name and value properties. + */ +type SaveNonArrayData = { + [k: string]: Entity; +}; + +/* +Entity data passed into save in an array form will be of type SaveArrayData +so will have name and value defined because the source code of save requires a +name and a value to be defined or else an error will be thrown. + */ +interface SaveArrayData { + name: { + toString(): string; + }; + value: Entity; + excludeFromIndexes?: boolean; +} + +/* +When saving an entity, data in the data property of the entity is of type +SaveDataValue. The data can either be in array form in which case it will +match the SaveArrayData[] data type or it can be in non-array form where +it will match the SaveNonArrayData data type. + */ +export type SaveDataValue = SaveArrayData[] | SaveNonArrayData; + +/* +An Entity passed into save will include a Key object contained either inside +a `key` property or inside a property indexed by the Key Symbol. If it is +the former then it will be of type SaveEntityWithoutKeySymbol. + */ +interface SaveEntityWithoutKeySymbol { + key: entity.Key; + data: SaveDataValue; + excludeFromIndexes?: string[]; +} + +/* +An Entity passed into save will include a Key object contained either inside +a `key` property or inside a property indexed by the Key Symbol. If it is +the latter then it will be of type SaveEntityWithKeySymbol. + */ +interface SaveEntityWithKeySymbol { + [entity.KEY_SYMBOL]: entity.Key; + data: SaveDataValue; +} + +/* +Entities passed into the first argument of the save function are expected to be +of type SaveEntity[] after being turned into an array. We could change the +signature of save later to enforce this, but doing so would be a breaking change +so we just cast this value to SaveEntity[] for now to enable strong type +enforcement throughout this function. + */ +export type SaveEntity = SaveEntityWithoutKeySymbol | SaveEntityWithKeySymbol; diff --git a/handwritten/nodejs-datastore/src/query.ts b/handwritten/nodejs-datastore/src/query.ts new file mode 100644 index 00000000000..86ff6ff45fc --- /dev/null +++ b/handwritten/nodejs-datastore/src/query.ts @@ -0,0 +1,649 @@ +/*! + * Copyright 2014 Google LLC. + * + * Licensed under the Apache License, Version 2.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. + */ + +import arrify = require('arrify'); +import {Key} from 'readline'; +import {Datastore} from '.'; +import {Entity} from './entity'; +import {EntityFilter, isFilter, AllowedFilterValueType} from './filter'; +import {Transaction} from './transaction'; +import {CallOptions} from 'google-gax'; +import {RunQueryStreamOptions} from '../src/request'; +import * as gaxInstance from 'google-gax'; +import {google} from '../protos/protos'; + +export type Operator = + | '=' + | '<' + | '>' + | '<=' + | '>=' + | 'HAS_ANCESTOR' + | '!=' + | 'IN' + | 'NOT_IN'; + +export interface OrderOptions { + descending?: boolean; +} + +export interface Order { + name: string; + sign: '-' | '+'; +} + +export interface Filter { + name: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + val: any; + op: Operator; +} + +/** + * A Query object is used to build and execute queries for entities stored in Datastore. + * + * Create a Query object with {@link Datastore#createQuery} or + * {@link Transaction#createQuery}. + * + * @see {@link http://goo.gl/Cag0r6| Datastore Queries} + * + * @class + * @param {Datastore|Transaction} scope The parent scope the query was created + * from. + * @param {string} [namespace] Namespace to query entities from. + * @param {string[]} kinds Kind to query. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const query = datastore.createQuery('AnimalNamespace', 'Lion'); + * ``` + */ +class Query { + scope?: Datastore | Transaction; + namespace?: string | null; + kinds: string[]; + filters: Filter[]; + entityFilters: EntityFilter[]; + orders: Order[]; + groupByVal: Array<{}>; + selectVal: Array<{}>; + startVal: string | Buffer | null; + endVal: string | Buffer | null; + limitVal: number; + offsetVal: number; + + constructor(scope?: Datastore | Transaction, kinds?: string[] | null); + constructor( + scope?: Datastore | Transaction, + namespace?: string | null, + kinds?: string[], + ); + constructor( + scope?: Datastore | Transaction, + namespaceOrKinds?: string | string[] | null, + kinds?: string[], + ) { + let namespace = namespaceOrKinds as string | null; + if (!kinds) { + kinds = namespaceOrKinds as string[]; + namespace = null; + } + + /** + * @name Query#scope + * @type {Datastore|Transaction} + */ + this.scope = scope; + + /** + * @name Query#namespace + * @type {?string} + */ + this.namespace = namespace || null; + /** + * @name Query#kinds + * @type {string} + */ + this.kinds = kinds; + + /** + * @name Query#filters + * @type {array} + */ + this.filters = []; + /** + * @name Query#entityFilters + * @type {array} + */ + this.entityFilters = []; + /** + * @name Query#orders + * @type {array} + */ + this.orders = []; + /** + * @name Query#groupByVal + * @type {array} + */ + this.groupByVal = []; + /** + * @name Query#selectVal + * @type {array} + */ + this.selectVal = []; + + // pagination + /** + * @name Query#startVal + * @type {?number} + */ + this.startVal = null; + /** + * @name Query#endVal + * @type {?number} + */ + this.endVal = null; + /** + * @name Query#limitVal + * @type {number} + */ + this.limitVal = -1; + /** + * @name Query#offsetVal + * @type {number} + */ + this.offsetVal = -1; + } + + /** + * Datastore allows querying on properties. Supported comparison operators + * are `=`, `<`, `>`, `<=`, `>=`, `!=`, `HAS_ANCESTOR`, `IN` and `NOT_IN`. + * + * *To filter by ancestors, see {module:datastore/query#hasAncestor}.* + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#datastore-property-filter-nodejs| Datastore Filters} + * + * @param {string | EntityFilter} propertyOrFilter The field name. + * @param {string} [operator="="] Operator (=, <, >, <=, >=). + * @param {*} value Value to compare property to. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const query = datastore.createQuery('Company'); + * + * //- + * // List all companies that are located in California. + * //- + * const caliQuery = query.filter('state', 'CA'); + * + * //- + * // List all companies named Google that have less than 400 employees. + * //- + * const companyQuery = query + * .filter('name', 'Google') + * .filter('size', '<', 400); + * + * //- + * // To filter by key, use `__key__` for the property name. Filter on keys + * // stored as properties is not currently supported. + * //- + * const key = datastore.key(['Company', 'Google']); + * const keyQuery = query.filter('__key__', key); + * ``` + */ + filter(filter: EntityFilter): Query; + filter( + property: T, + value: AllowedFilterValueType, + ): Query; + filter( + property: T, + operator: Operator, + value: AllowedFilterValueType, + ): Query; + filter( + propertyOrFilter: T | EntityFilter, + operatorOrValue?: Operator | AllowedFilterValueType, + value?: AllowedFilterValueType, + ): Query { + if (arguments.length > 1) { + gaxInstance.warn( + 'filter', + 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter', + ); + } + switch (arguments.length) { + case 1: { + if (isFilter(propertyOrFilter)) { + this.entityFilters.push(propertyOrFilter); + } + break; + } + case 2: { + this.filters.push({ + name: (propertyOrFilter as String).trim(), + op: '=', + val: operatorOrValue as AllowedFilterValueType, + }); + break; + } + case 3: { + this.filters.push({ + name: (propertyOrFilter as String).trim(), + op: (operatorOrValue as Operator).trim() as Operator, + val: value, + }); + } + } + return this; + } + + /** + * Filter a query by ancestors. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#datastore-ancestor-query-nodejs| Datastore Ancestor Filters} + * + * @param {Key} key Key object to filter by. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const query = datastore.createQuery('MyKind'); + * const ancestoryQuery = query.hasAncestor(datastore.key(['Parent', 123])); + * ``` + */ + hasAncestor(key: Key) { + this.filters.push({name: '__key__', op: 'HAS_ANCESTOR', val: key}); + return this; + } + + /** + * Sort the results by a property name in ascending or descending order. By + * default, an ascending sort order will be used. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#datastore-ascending-sort-nodejs| Datastore Sort Orders} + * + * @param {string} property The property to order by. + * @param {object} [options] Options object. + * @param {boolean} [options.descending=false] Sort the results by a property + * name in descending order. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const companyQuery = datastore.createQuery('Company'); + * + * // Sort by size ascendingly. + * const companiesAscending = companyQuery.order('size'); + * + * // Sort by size descendingly. + * const companiesDescending = companyQuery.order('size', { + * descending: true + * }); + * ``` + */ + order(property: string, options?: OrderOptions) { + const sign = options && options.descending ? '-' : '+'; + this.orders.push({name: property, sign}); + return this; + } + + /** + * Group query results by a list of properties. + * + * @param {array} properties Properties to group by. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const companyQuery = datastore.createQuery('Company'); + * const groupedQuery = companyQuery.groupBy(['name', 'size']); + * ``` + */ + groupBy(fieldNames: string | string[]) { + this.groupByVal = arrify(fieldNames); + return this; + } + + /** + * Retrieve only select properties from the matched entities. + * + * Queries that select a subset of properties are called Projection Queries. + * + * @see {@link https://cloud.google.com/datastore/docs/samples/datastore-projection-query| Projection Queries} + * + * @param {string|string[]} fieldNames Properties to return from the matched + * entities. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const companyQuery = datastore.createQuery('Company'); + * + * // Only retrieve the name property. + * const selectQuery = companyQuery.select('name'); + * + * // Only retrieve the name and size properties. + * const selectQuery = companyQuery.select(['name', 'size']); + * ``` + */ + select(fieldNames: string | string[]) { + this.selectVal = arrify(fieldNames); + return this; + } + + /** + * Set a starting cursor to a query. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets| Query Cursors} + * + * @param {string} cursorToken The starting cursor token. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const companyQuery = datastore.createQuery('Company'); + * + * const cursorToken = 'X'; + * + * // Retrieve results starting from cursorToken. + * const startQuery = companyQuery.start(cursorToken); + * ``` + */ + start(start: string | Buffer) { + this.startVal = start; + return this; + } + + /** + * Set an ending cursor to a query. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#Datastore_Query_cursors| Query Cursors} + * + * @param {string} cursorToken The ending cursor token. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const companyQuery = datastore.createQuery('Company'); + * + * const cursorToken = 'X'; + * + * // Retrieve results limited to the extent of cursorToken. + * const endQuery = companyQuery.end(cursorToken); + * ``` + */ + end(end: string | Buffer) { + this.endVal = end; + return this; + } + + /** + * Set a limit on a query. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#datastore-limit-nodejs| Query Limits} + * + * @param {number} n The number of results to limit the query to. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const companyQuery = datastore.createQuery('Company'); + * + * // Limit the results to 10 entities. + * const limitQuery = companyQuery.limit(10); + * ``` + */ + limit(n: number) { + this.limitVal = n; + return this; + } + + /** + * Set an offset on a query. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries#datastore-limit-nodejs| Query Offsets} + * + * @param {number} n The offset to start from after the start cursor. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const companyQuery = datastore.createQuery('Company'); + * + * // Start from the 101st result. + * const offsetQuery = companyQuery.offset(100); + * ``` + */ + offset(n: number) { + this.offsetVal = n; + return this; + } + + /** + * Run the query. + * + * @param {object} [options] Optional configuration. + * @param {string} [options.consistency] Specify either `strong` or `eventual`. + * If not specified, default values are chosen by Datastore for the + * operation. Learn more about strong and eventual consistency + * [here](https://cloud.google.com/datastore/docs/articles/balancing-strong-and-eventual-consistency-with-google-cloud-datastore). + * @param {object} [options.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {boolean | IntegerTypeCastOptions} [options.wrapNumbers=false] + * Wrap values of integerValue type in {@link Datastore#Int} objects. + * If a `boolean`, this will wrap values in {@link Datastore#Int} objects. + * If an `object`, this will return a value returned by + * `wrapNumbers.integerTypeCastFunction`. + * Please see {@link IntegerTypeCastOptions} for options descriptions. + * @param {function} [callback] The callback function. If omitted, a readable + * stream instance is returned. + * @param {?error} callback.err An error returned while making this request + * @param {object[]} callback.entities A list of entities. + * @param {object} callback.info An object useful for pagination. + * @param {?string} callback.info.endCursor Use this in a follow-up query to + * begin from where these results ended. + * @param {string} callback.info.moreResults Datastore responds with one of: + * + * - {@link Datastore#MORE_RESULTS_AFTER_LIMIT}: There *may* be more + * results after the specified limit. + * - {@link Datastore#MORE_RESULTS_AFTER_CURSOR}: There *may* be more + * results after the specified end cursor. + * - {@link Datastore#NO_MORE_RESULTS}: There are no more results. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const query = datastore.createQuery('Company'); + * + * query.run((err, entities, info) => { + * // entities = An array of records. + * + * // Access the Key object for an entity. + * const firstEntityKey = entities[0][datastore.KEY]; + * }); + * + * //- + * // A keys-only query returns just the keys of the result entities instead + * of + * // the entities themselves, at lower latency and cost. + * //- + * query.select('__key__'); + * + * query.run((err, entities) => { + * const keys = entities.map((entity) => { + * return entity[datastore.KEY]; + * }); + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * query.run().then((data) => { + * const entities = data[0]; + * }); + * ``` + */ + run(options?: RunQueryOptions): Promise; + run(options: RunQueryOptions, callback: RunQueryCallback): void; + run(callback: RunQueryCallback): void; + run( + optionsOrCallback?: RunQueryOptions | RunQueryCallback, + cb?: RunQueryCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + const runQuery = this.scope!.runQuery.bind(this.scope); + return runQuery(this, options, callback); + } + + /** + * Run the query as a readable object stream. + * + * @method Query#runStream + * @param {object} [options] Optional configuration. See + * {@link Query#run} for a complete list of options. + * @returns {stream} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const query = datastore.createQuery('Company'); + * + * query.runStream() + * .on('error', console.error) + * .on('data', function (entity) { + * // Access the Key object for this entity. + * const key = entity[datastore.KEY]; + * }) + * .on('info', (info) => {}) + * .on('end', () => { + * // All entities retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * query.runStream() + * .on('data', function (entity) { + * this.end(); + * }); + * ``` + */ + runStream(options?: RunQueryStreamOptions) { + return this.scope!.runQueryStream(this, options); + } +} + +export interface QueryProto { + startCursor?: string | Buffer; + distinctOn: {}; + kind: {}; + order: {}; + projection: {}; + endCursor?: string | Buffer; + limit?: {}; + offset?: number; + filter?: {}; +} + +/** + * Reference to the {@link Query} class. + * @name module:@google-cloud/datastore.Query + * @see Query + */ +export {Query}; + +export interface IntegerTypeCastOptions { + integerTypeCastFunction: Function; + properties?: string | string[]; +} + +export interface ExplainOptions { + analyze?: boolean; +} + +export interface RunQueryOptions { + consistency?: 'strong' | 'eventual'; + readTime?: number; + gaxOptions?: CallOptions; + explainOptions?: ExplainOptions; + wrapNumbers?: boolean | IntegerTypeCastOptions; +} + +export interface RunQueryCallback { + (err: Error | null, entities?: Entity[], info?: RunQueryInfo): void; +} + +export type RunQueryResponse = [Entity[], RunQueryInfo]; + +export type RunAggregateQueryResponse = any; + +export interface RunQueryInfo { + endCursor?: string; + moreResults?: + | 'MORE_RESULTS_TYPE_UNSPECIFIED' + | 'NOT_FINISHED' + | 'MORE_RESULTS_AFTER_LIMIT' + | 'MORE_RESULTS_AFTER_CURSOR' + | 'NO_MORE_RESULTS'; + explainMetrics?: ExplainMetrics; +} + +export interface ExplainMetrics { + planSummary?: PlanSummary; + executionStats?: ExecutionStats; +} +export interface ExecutionStats { + resultsReturned?: number; + executionDuration?: google.protobuf.IDuration; + readOperations?: number; + debugStats?: { + [key: string]: any; + }; +} + +export interface PlanSummary { + indexesUsed: { + [key: string]: any; + }[]; +} diff --git a/handwritten/nodejs-datastore/src/request.ts b/handwritten/nodejs-datastore/src/request.ts new file mode 100644 index 00000000000..dee2a09b2ce --- /dev/null +++ b/handwritten/nodejs-datastore/src/request.ts @@ -0,0 +1,1542 @@ +/*! + * Copyright 2014 Google LLC. + * + * Licensed under the Apache License, Version 2.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. + */ + +import {promisifyAll} from '@google-cloud/promisify'; +import arrify = require('arrify'); + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const concat = require('concat-stream'); +import * as extend from 'extend'; +import {split} from 'split-array-stream'; +import {google} from '../protos/protos'; +import {CallOptions, CancellableStream} from 'google-gax'; +import {Duplex, PassThrough, Transform} from 'stream'; + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const streamEvents = require('stream-events'); +export const transactionExpiredError = 'This transaction has already expired.'; + +export interface AbortableDuplex extends Duplex { + abort(): void; +} + +interface TransactionRequestOptions { + readOnly?: {}; + readWrite?: {previousTransaction?: string | Uint8Array | null}; +} + +// Import the clients for each version supported by this package. +const gapic = Object.freeze({ + v1: require('./v1'), +}); + +import { + entity, + Entity, + EntityProto, + KeyProto, + ResponseResult, + Entities, +} from './entity'; +import { + ExplainMetrics, + ExplainOptions, + Query, + QueryProto, + RunQueryInfo, + RunQueryOptions, + RunQueryResponse, + RunQueryCallback, +} from './query'; +import {Datastore, Transaction} from '.'; +import ITimestamp = google.protobuf.ITimestamp; +import {AggregateQuery} from './aggregate'; +import {RunOptions} from './transaction'; +import * as protos from '../protos/protos'; +import {serializer} from 'google-gax'; +import * as gax from 'google-gax'; +import {SaveDataValue} from './interfaces/save'; + +type JSONValue = + | string + | number + | boolean + | null + | JSONValue[] + | { + [key: string]: JSONValue; + }; + +const root = gax.protobuf.loadSync('google/protobuf/struct.proto'); +const Struct = root.lookupType('Struct'); + +// This function decodes Struct proto values +function decodeStruct(structValue: google.protobuf.IStruct): JSONValue { + return serializer.toProto3JSON(Struct.fromObject(structValue) as any); +} + +// This function gets a RunQueryInfo object that contains explain metrics that +// were returned from the server. +function getInfoFromStats( + resp: + | protos.google.datastore.v1.IRunQueryResponse + | protos.google.datastore.v1.IRunAggregationQueryResponse, +): RunQueryInfo { + // Decode struct values stored in planSummary and executionStats + const explainMetrics: ExplainMetrics = {}; + if ( + resp && + resp.explainMetrics && + resp.explainMetrics.planSummary && + resp.explainMetrics.planSummary.indexesUsed + ) { + Object.assign(explainMetrics, { + planSummary: { + indexesUsed: resp.explainMetrics.planSummary.indexesUsed.map( + (index: google.protobuf.IStruct) => decodeStruct(index), + ), + }, + }); + } + if (resp && resp.explainMetrics && resp.explainMetrics.executionStats) { + const executionStats = {}; + { + const resultsReturned = + resp.explainMetrics.executionStats.resultsReturned; + if (resultsReturned) { + Object.assign(executionStats, { + resultsReturned: + typeof resultsReturned === 'string' + ? parseInt(resultsReturned) + : resultsReturned, + }); + } + } + { + const executionDuration = + resp.explainMetrics.executionStats.executionDuration; + if (executionDuration) { + Object.assign(executionStats, { + executionDuration: + typeof executionDuration === 'string' + ? parseInt(executionDuration) + : executionDuration, + }); + } + } + { + const readOperations = resp.explainMetrics.executionStats.readOperations; + if (readOperations) { + Object.assign(executionStats, { + readOperations: + typeof readOperations === 'string' + ? parseInt(readOperations) + : readOperations, + }); + } + } + { + const debugStats = resp.explainMetrics.executionStats.debugStats; + if (debugStats) { + Object.assign(executionStats, {debugStats: decodeStruct(debugStats)}); + } + } + Object.assign(explainMetrics, {executionStats}); + } + if (explainMetrics.planSummary || explainMetrics.executionStats) { + return {explainMetrics}; + } + return {}; +} + +const readTimeAndConsistencyError = + 'Read time and read consistency cannot both be specified.'; + +// Write function to check for readTime and readConsistency. +function throwOnReadTimeAndConsistency(options: RunQueryStreamOptions) { + if (options.readTime && options.consistency) { + throw new Error(readTimeAndConsistencyError); + } +} + +/** + * A map of read consistency values to proto codes. + * + * @type {object} + * @private + */ +const CONSISTENCY_PROTO_CODE: ConsistencyProtoCode = { + eventual: 2, + strong: 1, +}; + +/** + * By default a DatastoreRequest is in the NOT_TRANSACTION state. If the + * DatastoreRequest is a Transaction object, then initially it will be in + * the NOT_STARTED state, but then the state will become IN_PROGRESS after the + * transaction has started. + */ +export enum TransactionState { + NOT_TRANSACTION, + NOT_STARTED, + IN_PROGRESS, + EXPIRED, +} + +/** + * Handles request logic for Datastore API operations. + * + * Creates requests to the Datastore endpoint. Designed to be inherited by + * the {@link Datastore} and {@link Transaction} classes. + * + * @class + */ +class DatastoreRequest { + id: string | undefined | Uint8Array | null; + requests_: + | Entity + | { + mutations: Array<{}>; + }; + requestCallbacks_: + | Array<(err: Error | null, resp: Entity | null) => void> + | Entity; + datastore!: Datastore; + protected state: TransactionState = TransactionState.NOT_TRANSACTION; + [key: string]: Entity; + + /** + * Format a user's input to mutation methods. This will create a deep clone of + * the input, as well as allow users to pass an object in the format of an + * entity. + * + * Both of the following formats can be supplied supported: + * + * datastore.save({ + * key: datastore.key('Kind'), + * data: { foo: 'bar' } + * }, (err) => {}) + * + * const entity = { foo: 'bar' } + * entity[datastore.KEY] = datastore.key('Kind') + * datastore.save(entity, (err) => {}) + * + * @internal + * + * @see {@link https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1803} + * + * @param {object} obj The user's input object. + */ + static prepareEntityObject_(obj: Entity): PrepareEntityObjectResponse { + const entityObject = extend(true, {}, obj); + + // Entity objects are also supported. + if (obj[entity.KEY_SYMBOL]) { + return { + key: obj[entity.KEY_SYMBOL], + data: entityObject, + }; + } + + return entityObject; + } + + /** + * Generate IDs without creating entities. + * + * @param {Key} key The key object to complete. + * @param {number|object} options Either the number of IDs to allocate or an + * options object for further customization of the request. + * @param {number} options.allocations How many IDs to allocate. + * @param {object} [options.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {array} callback.keys The generated IDs + * @param {object} callback.apiResponse The full API response. + * + * @example + * ``` + * const incompleteKey = datastore.key(['Company']); + * + * //- + * // The following call will create 100 new IDs from the Company kind, which + * // exists under the default namespace. + * //- + * datastore.allocateIds(incompleteKey, 100, (err, keys) => {}); + * + * //- + * // Or, if you're using a transaction object. + * //- + * const transaction = datastore.transaction(); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.allocateIds(incompleteKey, 100, (err, keys) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * }); + * + * //- + * // You may prefer to create IDs from a non-default namespace by providing + * an + * // incomplete key with a namespace. Similar to the previous example, the + * call + * // below will create 100 new IDs, but from the Company kind that exists + * under + * // the "ns-test" namespace. + * //- + * const incompleteKey = datastore.key({ + * namespace: 'ns-test', + * path: ['Company'] + * }); + * + * function callback(err, keys, apiResponse) {} + * + * datastore.allocateIds(incompleteKey, 100, callback); + * + * //- + * // Returns a Promise if callback is omitted. + * //- + * datastore.allocateIds(incompleteKey, 100).then((data) => { + * const keys = data[0]; + * const apiResponse = data[1]; + * }); + * ``` + */ + allocateIds( + key: entity.Key, + options: AllocateIdsOptions | number, + ): Promise; + allocateIds( + key: entity.Key, + options: AllocateIdsOptions | number, + callback: AllocateIdsCallback, + ): void; + allocateIds( + key: entity.Key, + options: AllocateIdsOptions | number, + callback?: AllocateIdsCallback, + ): void | Promise { + if (entity.isKeyComplete(key)) { + throw new Error('An incomplete key should be provided.'); + } + options = typeof options === 'number' ? {allocations: options} : options; + + this.request_( + { + client: 'DatastoreClient', + method: 'allocateIds', + reqOpts: { + keys: new Array(options.allocations).fill(entity.keyToKeyProto(key)), + }, + gaxOpts: options.gaxOptions, + }, + (err, resp) => { + if (err) { + callback!(err, null, resp!); + return; + } + const keys = arrify(resp!.keys!).map(entity.keyFromKeyProto); + callback!(null, keys, resp!); + }, + ); + } + + /* This throws an error if the transaction has already expired. + * + */ + protected checkExpired() { + if (this.state === TransactionState.EXPIRED) { + throw Error(transactionExpiredError); + } + } + + /** + * Retrieve the entities as a readable object stream. + * + * @throws {Error} If at least one Key object is not provided. + * @throws {Error} If read time and read consistency cannot both be specified. + * + * @param {Key|Key[]} keys Datastore key object(s). + * @param {object} [options] Optional configuration. See {@link Datastore#get} + * for a complete list of options. + * + * @example + * ``` + * const keys = [ + * datastore.key(['Company', 123]), + * datastore.key(['Product', 'Computer']) + * ]; + * + * datastore.createReadStream(keys) + * .on('error', (err) => {}) + * .on('data', (entity) => { + * // entity is an entity object. + * }) + * .on('end', () => { + * // All entities retrieved. + * }); + * ``` + */ + createReadStream( + keys: Entities, + options: CreateReadStreamOptions = {}, + ): Transform { + keys = arrify(keys).map(entity.keyToKeyProto); + if (keys.length === 0) { + throw new Error('At least one Key object is required.'); + } + this.checkExpired(); + throwOnReadTimeAndConsistency(options); + const reqOpts = this.getRequestOptions(options); + throwOnTransactionErrors(this, reqOpts); + const makeRequest = (keys: entity.Key[] | KeyProto[]) => { + Object.assign(reqOpts, {keys}); + this.request_( + { + client: 'DatastoreClient', + method: 'lookup', + reqOpts, + gaxOpts: options.gaxOptions, + }, + (err, resp) => { + this.parseTransactionResponse(resp); + if (err) { + stream.destroy(err); + return; + } + + let entities: Entity[] = []; + + try { + entities = entity.formatArray( + resp!.found! as ResponseResult[], + options.wrapNumbers, + ); + } catch (err) { + stream.destroy(err); + return; + } + const nextKeys = (resp!.deferred || []) + .map(entity.keyFromKeyProto) + .map(entity.keyToKeyProto); + + split(entities, stream) + .then(streamEnded => { + if (streamEnded) { + return; + } + + if (nextKeys.length > 0) { + makeRequest(nextKeys); + return; + } + + stream.push(null); + }) + .catch(err => { + throw err; + }); + }, + ); + }; + + const stream = streamEvents(new Transform({objectMode: true})); + stream.once('reading', () => { + makeRequest(keys); + }); + return stream; + } + + /** + * Delete all entities identified with the specified key(s). + * + * @param {Key|Key[]} key Datastore key object(s). + * @param {object} [gaxOptions] Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {object} callback.apiResponse The full API response. + * + * @example + * ``` + * const key = datastore.key(['Company', 123]); + * datastore.delete(key, (err, apiResp) => {}); + * + * //- + * // Or, if you're using a transaction object. + * //- + * const transaction = datastore.transaction(); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.delete(key); + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * + * //- + * // Delete multiple entities at once. + * //- + * datastore.delete([ + * datastore.key(['Company', 123]), + * datastore.key(['Product', 'Computer']) + * ], (err, apiResponse) => {}); + * + * //- + * // Returns a Promise if callback is omitted. + * //- + * datastore.delete().then((data) => { + * const apiResponse = data[0]; + * }); + * ``` + */ + delete(keys: Entities, gaxOptions?: CallOptions): Promise; + delete(keys: Entities, callback: DeleteCallback): void; + delete( + keys: Entities, + gaxOptions: CallOptions, + callback: DeleteCallback, + ): void; + delete( + keys: entity.Key | entity.Key[], + gaxOptionsOrCallback?: CallOptions | DeleteCallback, + cb?: DeleteCallback, + ): void | Promise { + const gaxOptions = + typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; + const callback = + typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb!; + + const reqOpts = { + mutations: arrify(keys).map(key => { + return { + delete: entity.keyToKeyProto(key), + }; + }), + // eslint-disable-next-line @typescript-eslint/no-explicit-any + } as any; + + if (this.id) { + this.requests_.push(reqOpts); + return; + } + + this.request_( + { + client: 'DatastoreClient', + method: 'commit', + reqOpts, + gaxOpts: gaxOptions, + }, + callback, + ); + } + + /** + * Retrieve the entities identified with the specified key(s) in the current + * transaction. Get operations require a valid key to retrieve the + * key-identified entity from Datastore. + * + * @throws {Error} If at least one Key object is not provided. + * + * @param {Key|Key[]} keys Datastore key object(s). + * @param {object} [options] Optional configuration. + * @param {string} [options.consistency] Specify either `strong` or `eventual`. + * If not specified, default values are chosen by Datastore for the + * operation. Learn more about strong and eventual consistency + * [here](https://cloud.google.com/datastore/docs/articles/balancing-strong-and-eventual-consistency-with-google-cloud-datastore). + * @param {object} [options.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {boolean | IntegerTypeCastOptions} [options.wrapNumbers=false] + * Wrap values of integerValue type in {@link Datastore#Int} objects. + * If a `boolean`, this will wrap values in {@link Datastore#Int} objects. + * If an `object`, this will return a value returned by + * `wrapNumbers.integerTypeCastFunction`. + * Please see {@link IntegerTypeCastOptions} for options descriptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {object|object[]} callback.entity The entity object(s) which match + * the provided keys. + * + * @example + * ``` + * //- + * // Get a single entity. + * //- + * const key = datastore.key(['Company', 123]); + * + * datastore.get(key, (err, entity) => {}); + * + * //- + * // Or, if you're using a transaction object. + * //- + * const transaction = datastore.transaction(); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.get(key, (err, entity) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * }); + * + * //- + * // Get multiple entities at once with a callback. + * //- + * const keys = [ + * datastore.key(['Company', 123]), + * datastore.key(['Product', 'Computer']) + * ]; + * + * datastore.get(keys, (err, entities) => {}); + * + * //- + * // Below is how to update the value of an entity with the help of the + * // `save` method. + * //- + * datastore.get(key, (err, entity) => { + * if (err) { + * // Error handling omitted. + * } + * + * entity.newValue = true; + * + * datastore.save({ + * key: key, + * data: entity + * }, (err) => {}); + * }); + * + * //- + * // Returns a Promise if callback is omitted. + * //- + * datastore.get(keys).then((data) => { + * const entities = data[0]; + * }); + * ``` + */ + get( + keys: entity.Key | entity.Key[], + options?: CreateReadStreamOptions, + ): Promise; + get(keys: entity.Key | entity.Key[], callback: GetCallback): void; + get( + keys: entity.Key | entity.Key[], + options: CreateReadStreamOptions, + callback: GetCallback, + ): void; + get( + keys: entity.Key | entity.Key[], + optionsOrCallback?: CreateReadStreamOptions | GetCallback, + cb?: GetCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' && optionsOrCallback + ? optionsOrCallback + : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + + try { + this.createReadStream(keys, options) + .on('error', callback) + .pipe( + concat((results: Entity[]) => { + const isSingleLookup = !Array.isArray(keys); + callback(null, isSingleLookup ? results[0] : results); + }), + ); + } catch (err: any) { + callback(err); + } + } + + /** + * This function saves results from a successful beginTransaction call. + * + * @param {object} [response] The response from a call to + * begin a transaction that completed successfully. + * + **/ + protected parseTransactionResponse(resp?: { + transaction?: Uint8Array | string | undefined | null; + }): void { + if (resp && resp.transaction && Buffer.byteLength(resp.transaction) > 0) { + this.id = resp!.transaction; + this.state = TransactionState.IN_PROGRESS; + } + } + + /** + * Datastore allows you to run aggregate queries by supplying aggregate fields + * which will determine the type of aggregation that is performed. + * + * The query is run, and the results are returned in the second argument of + * the callback provided. + * + * @param {AggregateQuery} query AggregateQuery object. + * @param {RunQueryOptions} options Optional configuration + * @param {function} [callback] The callback function. If omitted, a promise is + * returned. + * + * @throws {Error} If read time and read consistency cannot both be specified. + * + **/ + runAggregationQuery( + query: AggregateQuery, + options?: RunQueryOptions, + ): Promise; + runAggregationQuery( + query: AggregateQuery, + options: RunQueryOptions, + callback: RunAggregationQueryCallback, + ): void; + runAggregationQuery( + query: AggregateQuery, + callback: RunAggregationQueryCallback, + ): void; + runAggregationQuery( + query: AggregateQuery, + optionsOrCallback?: RunQueryOptions | RunAggregationQueryCallback, + cb?: RequestCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + + if (this.state === TransactionState.EXPIRED) { + callback(new Error(transactionExpiredError)); + return; + } + if (options.readTime && options.consistency) { + callback(new Error(readTimeAndConsistencyError)); + return; + } + query.query = extend(true, new Query(), query.query); + let queryProto: QueryProto; + try { + queryProto = entity.queryToQueryProto(query.query); + } catch (e) { + // using setImmediate here to make sure this doesn't throw a + // synchronous error + setImmediate(callback, e as Error); + return; + } + let sharedQueryOpts; + try { + sharedQueryOpts = this.getQueryOptions(query.query, options); + throwOnTransactionErrors(this, sharedQueryOpts); + } catch (error: any) { + callback(error); + return; + } + const aggregationQueryOptions: AggregationQueryOptions = { + nestedQuery: queryProto, + aggregations: query.toProto(), + }; + const reqOpts: RunAggregationQueryRequest = Object.assign(sharedQueryOpts, { + aggregationQuery: aggregationQueryOptions, + }); + this.request_( + { + client: 'DatastoreClient', + method: 'runAggregationQuery', + reqOpts, + gaxOpts: options.gaxOptions, + }, + (err, res) => { + const info = getInfoFromStats(res); + this.parseTransactionResponse(res); + if (res && res.batch) { + const results = res.batch.aggregationResults; + const finalResults = results + .map( + (aggregationResult: any) => aggregationResult.aggregateProperties, + ) + .map((aggregateProperties: any) => + Object.fromEntries( + new Map( + Object.keys(aggregateProperties).map(key => [ + key, + entity.decodeValueProto(aggregateProperties[key]), + ]), + ), + ), + ); + callback(err, finalResults, info); + } else { + callback(err, [], info); + } + }, + ); + } + + /** + * Datastore allows you to query entities by kind, filter them by property + * filters, and sort them by a property name. Projection and pagination are + * also supported. + * + * The query is run, and the results are returned as the second argument to + * your callback. A third argument may also exist, which is a query object + * that uses the end cursor from the previous query as the starting cursor for + * the next query. You can pass that object back to this method to see if more + * results exist. + * @param {Query} query A Query object + * @param {object} [options] Optional configuration. + * @param {string} [options.consistency] Specify either `strong` or `eventual`. + * If not specified, default values are chosen by Datastore for the + * operation. Learn more about strong and eventual consistency + * [here](https://cloud.google.com/datastore/docs/articles/balancing-strong-and-eventual-consistency-with-google-cloud-datastore). + * @param {object} [options.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {boolean | IntegerTypeCastOptions} [options.wrapNumbers=false] + * Wrap values of integerValue type in {@link Datastore#Int} objects. + * If a `boolean`, this will wrap values in {@link Datastore#Int} objects. + * If an `object`, this will return a value returned by + * `wrapNumbers.integerTypeCastFunction`. + * Please see {@link IntegerTypeCastOptions} for options descriptions. + * @param {function} [callback] The callback function. If omitted, a readable + * stream instance is returned. + * @param {?error} callback.err An error returned while making this request + * @param {object[]} callback.entities A list of entities. + * @param {object} callback.info An object useful for pagination. + * @param {?string} callback.info.endCursor Use this in a follow-up query to + * begin from where these results ended. + * @param {string} callback.info.moreResults Datastore responds with one of: + * + * - {@link Datastore#MORE_RESULTS_AFTER_LIMIT}: There *may* be more + * results after the specified limit. + * - {@link Datastore#MORE_RESULTS_AFTER_CURSOR}: There *may* be more + * results after the specified end cursor. + * - {@link Datastore#NO_MORE_RESULTS}: There are no more results. + * + * @example + * ``` + * //- + * // Where you see `transaction`, assume this is the context that's relevant + * to + * // your use, whether that be a Datastore or a Transaction object. + * //- + * const query = datastore.createQuery('Lion'); + * + * datastore.runQuery(query, (err, entities, info) => { + * // entities = An array of records. + * + * // Access the Key object for an entity. + * const firstEntityKey = entities[0][datastore.KEY]; + * }); + * + * //- + * // Or, if you're using a transaction object. + * //- + * const transaction = datastore.transaction(); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.runQuery(query, (err, entities) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * }); + * + * //- + * // A keys-only query returns just the keys of the result entities instead + * of + * // the entities themselves, at lower latency and cost. + * //- + * const keysOnlyQuery = datastore.createQuery('Lion').select('__key__'); + * + * datastore.runQuery(keysOnlyQuery, (err, entities) => { + * const keys = entities.map((entity) => { + * return entity[datastore.KEY]; + * }); + * }); + * + * //- + * // Returns a Promise if callback is omitted. + * //- + * datastore.runQuery(query).then((data) => { + * const entities = data[0]; + * }); + * ``` + */ + runQuery(query: Query, options?: RunQueryOptions): Promise; + runQuery( + query: Query, + options: RunQueryOptions, + callback: RunQueryCallback, + ): void; + runQuery(query: Query, callback: RunQueryCallback): void; + runQuery( + query: Query, + optionsOrCallback?: RunQueryOptions | RunQueryCallback, + cb?: RunQueryCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + + let info: RunQueryInfo; + + try { + this.runQueryStream(query, options) + .on('error', callback) + .on('info', info_ => { + info = info_; + }) + .pipe( + concat((results: Entity[]) => { + callback(null, results, info); + }), + ); + } catch (err: any) { + callback(err); + } + } + + /** + * Get a list of entities as a readable object stream. + * + * See {@link Datastore#runQuery} for a list of all available options. + * + * @param {Query} query A Query object + * @param {object} [options] Optional configuration. + * @param {object} [options.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * + * @throws {Error} If read time and read consistency cannot both be specified. + * + * @example + * ``` + * datastore.runQueryStream(query) + * .on('error', console.error) + * .on('data', (entity) => { + * // Access the Key object for this entity. + * const key = entity[datastore.KEY]; + * }) + * .on('info', (info) => {}) + * .on('end', () => { + * // All entities retrieved. + * }); + * + * //- + * // If you anticipate many results, you can end a stream early to prevent + * // unnecessary processing and API requests. + * //- + * datastore.runQueryStream(query) + * .on('data', (entity) => { + * this.end(); + * }); + * ``` + */ + runQueryStream(query: Query, options: RunQueryStreamOptions = {}): Transform { + this.checkExpired(); + throwOnReadTimeAndConsistency(options); + query = extend(true, new Query(), query); + const sharedQueryOpts = this.getQueryOptions(query, options); + throwOnTransactionErrors(this, sharedQueryOpts); + const makeRequest = (query: Query) => { + let queryProto: QueryProto; + try { + queryProto = entity.queryToQueryProto(query); + } catch (e) { + // using setImmediate here to make sure this doesn't throw a + // synchronous error + setImmediate(onResultSet, e as Error); + return; + } + + const reqOpts: RequestOptions = sharedQueryOpts; + reqOpts.query = queryProto; + this.request_( + { + client: 'DatastoreClient', + method: 'runQuery', + reqOpts, + gaxOpts: options.gaxOptions, + }, + onResultSet, + ); + }; + + const onResultSet = (err?: Error | null, resp?: Entity) => { + this.parseTransactionResponse(resp); + if (err) { + stream.destroy(err); + return; + } + + if (!resp.batch) { + // If there are no results then send any stats back and end the stream. + stream.emit('info', getInfoFromStats(resp)); + stream.push(null); + return; + } + + const info = Object.assign(getInfoFromStats(resp), { + moreResults: resp.batch.moreResults, + }); + + if (resp.batch.endCursor) { + info.endCursor = resp.batch.endCursor.toString('base64'); + } + + let entities: Entity[] = []; + + if (resp.batch.entityResults) { + try { + entities = entity.formatArray( + resp.batch.entityResults, + options.wrapNumbers, + ); + } catch (err) { + stream.destroy(err); + return; + } + } + + // Emit each result right away, then get the rest if necessary. + split(entities, stream) + .then(streamEnded => { + if (streamEnded) { + return; + } + + if (resp.batch.moreResults !== 'NOT_FINISHED') { + stream.emit('info', info); + stream.push(null); + return; + } + + // The query is "NOT_FINISHED". Get the rest of the results. + const offset = query.offsetVal === -1 ? 0 : query.offsetVal; + + query + .start(info.endCursor!) + .offset(offset - resp.batch.skippedResults); + + const limit = query.limitVal; + if (limit && limit > -1) { + query.limit(limit - resp.batch.entityResults.length); + } + + makeRequest(query); + }) + .catch(err => { + throw err; + }); + }; + + const stream = streamEvents(new Transform({objectMode: true})); + stream.once('reading', () => { + makeRequest(query); + }); + return stream; + } + + /** + * Gets request options from a RunQueryStream options configuration + * + * @param {RunQueryStreamOptions} [options] The RunQueryStream options configuration + */ + private getRequestOptions( + options: RunQueryStreamOptions, + ): SharedQueryOptions { + const sharedQueryOpts = {} as SharedQueryOptions; + if (isTransaction(this)) { + if (this.state === TransactionState.NOT_STARTED) { + if (sharedQueryOpts.readOptions === undefined) { + sharedQueryOpts.readOptions = {}; + } + sharedQueryOpts.readOptions.newTransaction = getTransactionRequest( + this, + {}, + ); + sharedQueryOpts.readOptions.consistencyType = 'newTransaction'; + } + } + if (options.consistency) { + const code = CONSISTENCY_PROTO_CODE[options.consistency.toLowerCase()]; + if (sharedQueryOpts.readOptions === undefined) { + sharedQueryOpts.readOptions = {}; + } + sharedQueryOpts.readOptions.readConsistency = code; + } + if (options.readTime) { + if (sharedQueryOpts.readOptions === undefined) { + sharedQueryOpts.readOptions = {}; + } + const readTime = options.readTime; + const seconds = readTime / 1000; + sharedQueryOpts.readOptions.readTime = { + seconds: Math.floor(seconds), + }; + } + return sharedQueryOpts; + } + + /** + * Gets request options from a RunQueryStream options configuration + * + * @param {Query} [query] A Query object + * @param {RunQueryStreamOptions} [options] The RunQueryStream options configuration + */ + private getQueryOptions( + query: Query, + options: RunQueryStreamOptions = {}, + ): SharedQueryOptions { + const sharedQueryOpts = this.getRequestOptions(options); + if (options.explainOptions) { + sharedQueryOpts.explainOptions = options.explainOptions; + } + if (query.namespace) { + sharedQueryOpts.partitionId = { + namespaceId: query.namespace, + }; + } + return sharedQueryOpts; + } + + /** + * Merge the specified object(s). If a key is incomplete, its associated object + * is inserted and the original Key object is updated to contain the generated ID. + * For example, if you provide an incomplete key (one without an ID), + * the request will create a new entity and have its ID automatically assigned. + * If you provide a complete key, the entity will be get the data from datastore + * and merge with the data specified. + * By default, all properties are indexed. To prevent a property from being + * included in *all* indexes, you must supply an `excludeFromIndexes` array. + * + * Maps to {@link Datastore#save}, forcing the method to be `upsert`. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entities.data Data to merge to the same for provided key. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request + * @param {object} callback.apiResponse The full API response. + */ + merge(entities: Entities): Promise; + merge(entities: Entities, callback: SaveCallback): void; + merge( + entities: Entities, + callback?: SaveCallback, + ): void | Promise { + const transaction = this.datastore.transaction(); + transaction.run(async (err: any) => { + if (err) { + try { + await transaction.rollback(); + } catch (error) { + // Provide the error & API response from the failed run to the user. + // Even a failed rollback should be transparent. + // RE: https://github.com/GoogleCloudPlatform/gcloud-node/pull/1369#discussion_r66833976 + } + callback!(err); + return; + } + try { + await Promise.all( + arrify(entities).map(async (objEntity: Entity) => { + const obj: Entity = + DatastoreRequest.prepareEntityObject_(objEntity); + const [data] = await transaction.get(obj.key); + obj.method = 'upsert'; + obj.data = Object.assign({}, data, obj.data); + transaction.save(obj); + }), + ); + + const [response] = await transaction.commit(); + callback!(null, response); + } catch (err) { + try { + await transaction.rollback(); + } catch (error) { + // Provide the error & API response from the failed commit to the user. + // Even a failed rollback should be transparent. + // RE: https://github.com/GoogleCloudPlatform/gcloud-node/pull/1369#discussion_r66833976 + } + callback!(err as Error); + } + }); + } + + /** + * Builds a request and sends it to the Gapic Layer. + * + * @param {object} config Configuration object. + * @param {function} callback The callback function. + * + * @private + */ + prepareGaxRequest_(config: RequestConfig, callback: Function): void { + const datastore = this.datastore; + + const isTransaction = this.id ? true : false; + const method = config.method; + const reqOpts = extend(true, {}, config.reqOpts); + + // Set properties to indicate if we're in a transaction or not. + if (method === 'commit') { + if (isTransaction) { + reqOpts.mode = 'TRANSACTIONAL'; + reqOpts.transaction = this.id; + } else { + reqOpts.mode = 'NON_TRANSACTIONAL'; + } + } + + if (datastore.options && datastore.options.databaseId) { + reqOpts.databaseId = datastore.options.databaseId; + } + + if (method === 'rollback') { + reqOpts.transaction = this.id; + } + throwOnTransactionErrors(this, reqOpts); + if ( + isTransaction && + (method === 'lookup' || + method === 'runQuery' || + method === 'runAggregationQuery') + ) { + if (reqOpts.readOptions) { + Object.assign(reqOpts.readOptions, {transaction: this.id}); + } else { + reqOpts.readOptions = { + transaction: this.id, + }; + } + } + + datastore.auth.getProjectId((err, projectId) => { + if (err) { + callback!(err); + return; + } + const clientName = config.client; + if (!datastore.clients_.has(clientName)) { + datastore.clients_.set( + clientName, + new gapic.v1[clientName](datastore.options), + ); + } + const gaxClient = datastore.clients_.get(clientName); + reqOpts.projectId = projectId!; + const gaxOpts = extend(true, {}, config.gaxOpts, { + headers: { + 'google-cloud-resource-prefix': `projects/${projectId}`, + }, + }); + const requestFn = gaxClient![method].bind(gaxClient, reqOpts, gaxOpts); + callback(null, requestFn); + }); + } + + /** + * Make a request to the API endpoint. Properties to indicate a transactional + * or non-transactional operation are added automatically. + * + * @param {object} config Configuration object. + * @param {object} config.gaxOpts GAX options. + * @param {string} config.client The name of the gax client. + * @param {function} config.method The gax method to call. + * @param {object} config.reqOpts Request options. + * @param {function} callback The callback function. + * + * @private + */ + request_(config: RequestConfig, callback: RequestCallback): void; + request_(config: RequestConfig, callback: RequestCallback): void { + this.prepareGaxRequest_(config, (err: Error, requestFn: Function) => { + if (err) { + callback(err); + return; + } + requestFn(callback); + }); + } + + /** + * Make a request as a stream. + * + * @param {object} config Configuration object. + * @param {object} config.gaxOpts GAX options. + * @param {string} config.client The name of the gax client. + * @param {string} config.method The gax method to call. + * @param {object} config.reqOpts Request options. + */ + requestStream_(config: RequestConfig): AbortableDuplex { + let gaxStream: CancellableStream; + const stream = streamEvents(new PassThrough({objectMode: true})); + + stream.abort = () => { + if (gaxStream && gaxStream.cancel) { + gaxStream.cancel(); + } + }; + + stream.once('reading', () => { + this.prepareGaxRequest_(config, (err: Error, requestFn: Function) => { + if (err) { + stream.destroy(err); + return; + } + + gaxStream = requestFn(); + gaxStream + .on('error', stream.destroy.bind(stream)) + .on('response', stream.emit.bind(stream, 'response')) + .pipe(stream); + }); + }); + + return stream as AbortableDuplex; + } +} + +/** + * Check to see if a request is a Transaction + * + * @param {DatastoreRequest} request The Datastore request object + * + */ +function isTransaction(request: DatastoreRequest): request is Transaction { + return request instanceof Transaction; +} + +/** + * Throw an error if read options are not properly specified. + * + * @param {DatastoreRequest} request The Datastore request object + * @param {SharedQueryOptions} options The Query options + * + */ +function throwOnTransactionErrors( + request: DatastoreRequest, + options: SharedQueryOptions, +) { + const isTransaction = request.id ? true : false; + if ( + isTransaction || + (options.readOptions && options.readOptions.newTransaction) + ) { + if (options.readOptions && options.readOptions.readConsistency) { + throw new Error('Read consistency cannot be specified in a transaction.'); + } + if (options.readOptions && options.readOptions.readTime) { + throw new Error('Read time cannot be specified in a transaction.'); + } + } +} + +/** + * This function gets transaction request options used for defining a + * request to create a new transaction on the server. + * + * @param {Transaction} transaction The transaction for which the request will be made. + * @param {RunOptions} options Custom options that will be used to create the request. + */ +export function getTransactionRequest( + transaction: Transaction, + options: RunOptions, +): TransactionRequestOptions { + // If transactionOptions are provide then they will be used. + // Otherwise, options passed into this function are used and when absent + // options that exist on Transaction are used. + return options.transactionOptions // If transactionOptions is specified: + ? options.transactionOptions.readOnly // Use readOnly on transactionOptions + ? {readOnly: {}} + : options.transactionOptions.id // Use retry transaction if specified: + ? {readWrite: {previousTransaction: options.transactionOptions.id}} + : {} + : options.readOnly || transaction.readOnly // If transactionOptions not set: + ? {readOnly: {}} // Create a readOnly transaction if readOnly option set + : options.transactionId || transaction.id + ? { + // Create readWrite transaction with a retry transaction set + readWrite: { + previousTransaction: options.transactionId || transaction.id, + }, + } + : {}; // Request will be readWrite with no retry transaction set; +} + +export interface ConsistencyProtoCode { + [key: string]: number; +} +export type AllocateIdsResponse = [ + entity.Key[], + google.datastore.v1.IAllocateIdsResponse, +]; +export interface AllocateIdsCallback { + ( + a: Error | null, + b: entity.Key[] | null, + c: google.datastore.v1.IAllocateIdsResponse, + ): void; +} +export interface AllocateIdsOptions { + allocations?: number; + gaxOptions?: CallOptions; +} +export type CreateReadStreamOptions = RunQueryOptions; +export interface GetCallback { + (err?: Error | null, entity?: Entities): void; +} +export type GetResponse = [Entities]; +export interface Mutation { + [key: string]: EntityProto; +} +export interface PrepareEntityObject { + [key: string]: google.datastore.v1.Key | undefined; +} +export interface PrepareEntityObjectResponse { + key?: entity.Key; + data?: SaveDataValue; + excludeFromIndexes?: string[]; + excludeLargeProperties?: boolean; + method?: string; +} +export interface RequestCallback { + ( + a?: Error | null, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + b?: any, + ): void; +} +export interface RunAggregationQueryCallback { + ( + a?: Error | null, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + b?: any, + c?: RunQueryInfo, + ): void; +} +export interface RequestConfig { + client: string; + gaxOpts?: CallOptions; + method: string; + prepared?: boolean; + reqOpts?: RequestOptions; +} +export interface SharedQueryOptions { + databaseId?: string; + explainOptions?: ExplainOptions; + projectId?: string; + partitionId?: google.datastore.v1.IPartitionId | null; + readOptions?: { + readConsistency?: number; + transaction?: string | Uint8Array | null; + readTime?: ITimestamp; + newTransaction?: TransactionRequestOptions; + consistencyType?: + | 'readConsistency' + | 'transaction' + | 'newTransaction' + | 'readTime'; + }; +} +export interface RequestOptions extends SharedQueryOptions { + mutations?: google.datastore.v1.IMutation[]; + keys?: Entity; + transactionOptions?: TransactionRequestOptions | null; + transaction?: string | null | Uint8Array; + mode?: string; + query?: QueryProto; + filter?: string; + indexId?: string; + entityFilter?: google.datastore.admin.v1.IEntityFilter; +} +export interface RunAggregationQueryRequest extends SharedQueryOptions { + aggregationQuery: AggregationQueryOptions; +} +export interface AggregationQueryOptions { + nestedQuery: QueryProto; + aggregations: Array; +} +export type RunQueryStreamOptions = RunQueryOptions; +export interface CommitCallback { + (err?: Error | null, resp?: google.datastore.v1.ICommitResponse): void; +} +export type CommitResponse = [google.datastore.v1.ICommitResponse]; +export type SaveCallback = CommitCallback; +export type SaveResponse = CommitResponse; +export type DeleteCallback = CommitCallback; +export type DeleteResponse = CommitResponse; + +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +promisifyAll(DatastoreRequest, { + exclude: ['checkExpired', 'getQueryOptions', 'getRequestOptions'], +}); + +/** + * Reference to the {@link DatastoreRequest} class. + * @name module:@google-cloud/datastore.DatastoreRequest + * @see DatastoreRequest + */ +export {DatastoreRequest}; diff --git a/handwritten/nodejs-datastore/src/transaction.ts b/handwritten/nodejs-datastore/src/transaction.ts new file mode 100644 index 00000000000..2525b0090ba --- /dev/null +++ b/handwritten/nodejs-datastore/src/transaction.ts @@ -0,0 +1,1120 @@ +/*! + * Copyright 2014 Google LLC. + * + * Licensed under the Apache License, Version 2.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. + */ + +import {promisifyAll} from '@google-cloud/promisify'; +import {CallOptions} from 'google-gax'; + +import {google} from '../protos/protos'; + +import {Datastore, TransactionOptions} from '.'; +import {Entities, Entity, entity} from './entity'; +import { + Query, + RunQueryCallback, + RunQueryOptions, + RunQueryResponse, +} from './query'; +import { + CommitCallback, + CommitResponse, + CreateReadStreamOptions, + DatastoreRequest, + GetCallback, + GetResponse, + getTransactionRequest, + PrepareEntityObjectResponse, + RequestCallback, + transactionExpiredError, + TransactionState, +} from './request'; +import {AggregateQuery} from './aggregate'; +import {Mutex} from 'async-mutex'; +import arrify = require('arrify'); + +/* + * This type matches the value returned by the promise in the + * #beginTransactionAsync function and subsequently passed into various other + * methods in this class. + */ +interface BeginAsyncResponse { + err?: Error | null; + resp?: google.datastore.v1.IBeginTransactionResponse; +} + +/** + * A transaction is a set of Datastore operations on one or more entities. Each + * transaction is guaranteed to be atomic, which means that transactions are + * never partially applied. Either all of the operations in the transaction are + * applied, or none of them are applied. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/transactions| Transactions Reference} + * + * @class + * @extends {Request} + * @param {Datastore} datastore A Datastore instance. + * @mixes module:datastore/request + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * ``` + */ +class Transaction extends DatastoreRequest { + namespace?: string; + readOnly: boolean; + request: Function; + modifiedEntities_: ModifiedEntities; + skipCommit?: boolean; + #mutex = new Mutex(); + constructor(datastore: Datastore, options?: TransactionOptions) { + super(); + /** + * @name Transaction#datastore + * @type {Datastore} + */ + this.datastore = datastore; + + /** + * @name Transaction#namespace + * @type {string} + */ + this.namespace = datastore.namespace; + + options = options || {}; + + this.id = options.id; + this.readOnly = options.readOnly === true; + + this.request = datastore.request_.bind(datastore); + + // A queue for entity modifications made during the transaction. + this.modifiedEntities_ = []; + + // Queue the callbacks that process the API responses. + this.requestCallbacks_ = []; + + // Queue the requests to make when we send the transactional commit. + this.requests_ = []; + this.state = TransactionState.NOT_STARTED; + } + + /*! Developer Documentation + * + * Below, we override two methods that we inherit from DatastoreRequest: + * `delete` and `save`. This is done because: + * + * A) the documentation needs to be different for a transactional save, and + * B) we build up a "modifiedEntities_" array on this object, used to build + * the final commit request with. + */ + + /** + * Commit the remote transaction and finalize the current transaction + * instance. + * + * If the commit request fails, we will automatically rollback the + * transaction. + * + * @param {CallOptions | https://googleapis.github.io/gax-nodejs/global.html#CallOptions} [gaxOptions] Request configuration options. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request. + * If the commit fails, we automatically try to rollback the transaction + * (see {module:datastore/transaction#rollback}). + * @param {object} callback.apiResponse The full API response. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * + * transaction.commit((err, apiResponse) => { + * if (err) { + * // Transaction could not be committed. + * } + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * transaction.commit().then((data) => { + * const apiResponse = data[0]; + * }); + * ``` + */ + commit(gaxOptions?: CallOptions): Promise; + /** + * @param {object} [gaxOptions] Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request. + * If the commit fails, we automatically try to rollback the transaction + * (see {module:datastore/transaction#rollback}). + * @param {object} callback.apiResponse The full API response. + */ + commit(callback: CommitCallback): void; + commit(gaxOptions: CallOptions, callback: CommitCallback): void; + commit( + gaxOptionsOrCallback?: CallOptions | CommitCallback, + cb?: CommitCallback, + ): void | Promise { + const callback = + typeof gaxOptionsOrCallback === 'function' + ? gaxOptionsOrCallback + : typeof cb === 'function' + ? cb + : () => {}; + const gaxOptions = + typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; + if (this.state === TransactionState.EXPIRED) { + callback(new Error(transactionExpiredError)); + return; + } + // This ensures that the transaction is started before calling runCommit + this.#withBeginTransaction( + gaxOptions, + () => { + void this.#runCommit(gaxOptions, callback); + }, + callback, + ); + } + + /** + * Create a query for the specified kind. See {module:datastore/query} for all + * of the available methods. + * + * @see {@link https://cloud.google.com/datastore/docs/concepts/queries| Datastore Queries} + * + * @see {@link Query} + * + * @param {string} [namespace] Namespace. + * @param {string} kind The kind to query. + * @returns {Query} + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * + * // Run the query inside the transaction. + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * const ancestorKey = datastore.key(['ParentCompany', 'Alphabet']); + * + * const query = transaction.createQuery('Company') + * .hasAncestor(ancestorKey); + * + * query.run((err, entities) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * }); + * + * // Run the query inside the transaction.with namespace + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * const ancestorKey = datastore.key(['ParentCompany', 'Alphabet']); + * + * const query = transaction.createQuery('CompanyNamespace', 'Company') + * .hasAncestor(ancestorKey); + * + * query.run((err, entities) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * }); + * ``` + */ + createQuery(kind?: string): Query; + createQuery(kind?: string[]): Query; + createQuery(namespace: string, kind: string): Query; + createQuery(namespace: string, kind: string[]): Query; + createQuery( + namespaceOrKind?: string | string[], + kind?: string | string[], + ): Query { + return this.datastore.createQuery.call( + this, + namespaceOrKind as string, + kind as string[], + ); + } + + /** + * Create an aggregation query from the query specified. See {module:datastore/query} for all + * of the available methods. + * + * @param {Query} query A Query object + */ + createAggregationQuery(query: Query): AggregateQuery { + return this.datastore.createAggregationQuery.call(this, query); + } + + /** + * Delete all entities identified with the specified key(s) in the current + * transaction. + * + * @param {Key|Key[]} key Datastore key object(s). + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * // Delete a single entity. + * transaction.delete(datastore.key(['Company', 123])); + * + * // Delete multiple entities at once. + * transaction.delete([ + * datastore.key(['Company', 123]), + * datastore.key(['Product', 'Computer']) + * ]); + * + * transaction.commit((err) => { + * if (!err) { + * // Transaction committed successfully. + * } + * }); + * }); + * ``` + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + delete(entities?: Entities): any { + arrify(entities).forEach((ent: Entity) => { + this.modifiedEntities_.push({ + entity: { + key: ent, + }, + method: 'delete', + args: [ent], + }); + }); + } + + /** + * This function calls get on the super class. If the transaction + * has not been started yet then the transaction is started before the + * get call is made. + * + * @param {Key|Key[]} keys Datastore key object(s). + * @param {object} [options] Optional configuration. + * @param {function} callback The callback function. + * + */ + get( + keys: entity.Key | entity.Key[], + options?: CreateReadStreamOptions, + ): Promise; + get(keys: entity.Key | entity.Key[], callback: GetCallback): void; + get( + keys: entity.Key | entity.Key[], + options: CreateReadStreamOptions, + callback: GetCallback, + ): void; + get( + keys: entity.Key | entity.Key[], + optionsOrCallback?: CreateReadStreamOptions | GetCallback, + cb?: GetCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' && optionsOrCallback + ? optionsOrCallback + : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + // This ensures that the transaction is started before calling get + this.#blockWithMutex(() => { + super.get(keys, options, callback); + }); + } + + /** + * Maps to {@link https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/transaction#_google_cloud_datastore_Transaction_save_member_1_|Datastore#save}, forcing the method to be `insert`. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entities.data Data to save with the provided key. + */ + insert(entities: Entities): void { + entities = arrify(entities) + .map(DatastoreRequest.prepareEntityObject_) + .map((x: PrepareEntityObjectResponse) => { + x.method = 'insert'; + return x; + }); + + this.save(entities); + } + + /** + * Reverse a transaction remotely and finalize the current transaction + * instance. + * + * @param {object} [gaxOptions] Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @param {?error} callback.err An error returned while making this request. + * @param {object} callback.apiResponse The full API response. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.rollback((err) => { + * if (!err) { + * // Transaction rolled back successfully. + * } + * }); + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * transaction.rollback().then((data) => { + * const apiResponse = data[0]; + * }); + * ``` + */ + rollback(callback: RollbackCallback): void; + rollback(gaxOptions?: CallOptions): Promise; + rollback(gaxOptions: CallOptions, callback: RollbackCallback): void; + rollback( + gaxOptionsOrCallback?: CallOptions | RollbackCallback, + cb?: RollbackCallback, + ): void | Promise { + const gaxOptions = + typeof gaxOptionsOrCallback === 'object' ? gaxOptionsOrCallback : {}; + const callback = + typeof gaxOptionsOrCallback === 'function' ? gaxOptionsOrCallback : cb!; + + if (this.state === TransactionState.EXPIRED) { + callback(new Error(transactionExpiredError)); + return; + } + if (this.state === TransactionState.NOT_STARTED) { + callback(new Error('Transaction is not started')); + return; + } + this.request_( + { + client: 'DatastoreClient', + method: 'rollback', + gaxOpts: gaxOptions || {}, + }, + (err, resp) => { + this.skipCommit = true; + this.state = TransactionState.EXPIRED; + callback(err || null, resp); + }, + ); + } + + /** + * Begin a remote transaction. In the callback provided, run your + * transactional commands. + * + * @param {object} [options] Configuration object. + * @param {object} [options.gaxOptions] Request configuration options, outlined + * here: https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {boolean} [options.readOnly=false] A read-only transaction cannot + * modify entities. + * @param {string} [options.transactionId] The ID of a previous transaction. + * @param {function} callback The function to execute within the context of + * a transaction. + * @param {?error} callback.err An error returned while making this request. + * @param {Transaction} callback.transaction This transaction + * instance. + * @param {object} callback.apiResponse The full API response. + * + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * + * transaction.run((err, transaction) => { + * // Perform Datastore transactional operations. + * const key = datastore.key(['Company', 123]); + * + * transaction.get(key, (err, entity) => { + * entity.name = 'Google'; + * + * transaction.save({ + * key: key, + * data: entity + * }); + * + * transaction.commit((err) => { + * if (!err) { + * // Data saved successfully. + * } + * }); + * }); + * }); + * + * //- + * // If the callback is omitted, we'll return a Promise. + * //- + * transaction.run().then((data) => { + * const transaction = data[0]; + * const apiResponse = data[1]; + * }); + * ``` + */ + run(options?: RunOptions): Promise; + run(callback: RunCallback): void; + run(options: RunOptions, callback: RunCallback): void; + run( + optionsOrCallback?: RunOptions | RunCallback, + cb?: RunCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' ? optionsOrCallback : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + void this.#mutex.runExclusive(async () => { + if (this.state === TransactionState.NOT_STARTED) { + const runResults = await this.#beginTransactionAsync(options); + this.#processBeginResults(runResults, callback); + } else { + process.emitWarning( + 'run has already been called and should not be called again.', + ); + callback(null, this, {transaction: this.id}); + } + }); + } + + /** + * This function is a pass-through for the transaction.commit method + * It contains the business logic used for committing a transaction + * + * @param {object} [gaxOptions] Request configuration options, outlined here: + * https://googleapis.github.io/gax-nodejs/global.html#CallOptions. + * @param {function} callback The callback function. + * @private + */ + #runCommit( + gaxOptions: CallOptions, + callback: CommitCallback, + ): void | Promise { + if (this.skipCommit) { + setImmediate(callback); + return; + } + + const keys: Entities = {}; + + this.modifiedEntities_ + // Reverse the order of the queue to respect the "last queued request + // wins" behavior. + .reverse() + // Limit the operations we're going to send through to only the most + // recently queued operations. E.g., if a user tries to save with the + // same key they just asked to be deleted, the delete request will be + // ignored, giving preference to the save operation. + .filter((modifiedEntity: Entity) => { + const key = modifiedEntity.entity.key; + + if (!entity.isKeyComplete(key)) return true; + + const stringifiedKey = JSON.stringify(modifiedEntity.entity.key); + + if (!keys[stringifiedKey]) { + keys[stringifiedKey] = true; + return true; + } + + return false; + }) + // Group entities together by method: `save` mutations, then `delete`. + // Note: `save` mutations being first is required to maintain order when + // assigning IDs to incomplete keys. + .sort((a, b) => { + return a.method < b.method ? 1 : a.method > b.method ? -1 : 0; + }) + // Group arguments together so that we only make one call to each + // method. This is important for `DatastoreRequest.save`, especially, as + // that method handles assigning auto-generated IDs to the original keys + // passed in. When we eventually execute the `save` method's API + // callback, having all the keys together is necessary to maintain + // order. + .reduce((acc: Entities, entityObject: Entity) => { + const lastEntityObject = acc[acc.length - 1]; + const sameMethod = + lastEntityObject && entityObject.method === lastEntityObject.method; + + if (!lastEntityObject || !sameMethod) { + acc.push(entityObject); + } else { + lastEntityObject.args = lastEntityObject.args.concat( + entityObject.args, + ); + } + + return acc; + }, []) + // Call each of the mutational methods (DatastoreRequest[save,delete]) + // to build up a `req` array on this instance. This will also build up a + // `callbacks` array, that is the same callback that would run if we + // were using `save` and `delete` outside of a transaction, to process + // the response from the API. + .forEach( + (modifiedEntity: {method: string; args: {reverse: () => void}}) => { + const method = modifiedEntity.method; + const args = modifiedEntity.args.reverse(); + Datastore.prototype[method].call(this, args, () => {}); + }, + ); + + // Take the `req` array built previously, and merge them into one request to + // send as the final transactional commit. + const reqOpts = { + mutations: this.requests_ + .map((x: {mutations: google.datastore.v1.Mutation}) => x.mutations) + .reduce( + (a: {concat: (arg0: Entity) => void}, b: Entity) => a.concat(b), + [], + ), + }; + + this.request_( + { + client: 'DatastoreClient', + method: 'commit', + reqOpts, + gaxOpts: gaxOptions || {}, + }, + (err, resp) => { + if (err) { + // Rollback automatically for the user. + this.rollback(() => { + // Provide the error & API response from the failed commit to the + // user. Even a failed rollback should be transparent. RE: + // https://github.com/GoogleCloudPlatform/google-cloud-node/pull/1369#discussion_r66833976 + callback(err, resp); + }); + return; + } + + this.state = TransactionState.EXPIRED; + // The `callbacks` array was built previously. These are the callbacks + // that handle the API response normally when using the + // DatastoreRequest.save and .delete methods. + this.requestCallbacks_.forEach( + (cb: (arg0: null, arg1: Entity) => void) => { + cb(null, resp); + }, + ); + callback(null, resp); + }, + ); + } + + /** + * This function parses results from a beginTransaction call + * + * @param {BeginAsyncResponse} [response] + * The response data from a call to begin a transaction. + * @param {RunCallback} [callback] A callback that accepts an error and a + * response as arguments. + * + **/ + #processBeginResults( + runResults: BeginAsyncResponse, + callback: RunCallback, + ): void { + const err = runResults.err; + const resp = runResults.resp; + if (err) { + callback(err, null, resp); + } else { + this.parseTransactionResponse(resp); + callback(null, this, resp); + } + } + + /** + * This async function makes a beginTransaction call and returns a promise with + * the information returned from the call that was made. + * + * @param {RunOptions} options The options used for a beginTransaction call. + * @returns {Promise} + * + * + **/ + async #beginTransactionAsync( + options: RunOptions, + ): Promise { + return new Promise((resolve: (value: BeginAsyncResponse) => void) => { + const reqOpts = { + transactionOptions: getTransactionRequest(this, options), + }; + this.request_( + { + client: 'DatastoreClient', + method: 'beginTransaction', + reqOpts, + gaxOpts: options.gaxOptions, + }, + // Always use resolve because then this function can return both the error and the response + (err, resp) => { + resolve({ + err, + resp, + }); + }, + ); + }); + } + + /** + * + * This function calls runAggregationQuery on the super class. If the transaction + * has not been started yet then the transaction is started before the + * runAggregationQuery call is made. + * + * @param {AggregateQuery} [query] AggregateQuery object. + * @param {RunQueryOptions} [options] Optional configuration + * @param {function} [callback] The callback function. If omitted, a promise is + * returned. + * + **/ + runAggregationQuery( + query: AggregateQuery, + options?: RunQueryOptions, + ): Promise; + runAggregationQuery( + query: AggregateQuery, + options: RunQueryOptions, + callback: RequestCallback, + ): void; + runAggregationQuery(query: AggregateQuery, callback: RequestCallback): void; + runAggregationQuery( + query: AggregateQuery, + optionsOrCallback?: RunQueryOptions | RequestCallback, + cb?: RequestCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' && optionsOrCallback + ? optionsOrCallback + : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + // This ensures that the transaction is started before calling runAggregationQuery + this.#blockWithMutex(() => { + super.runAggregationQuery(query, options, callback); + }); + } + + /** + * This function calls runQuery on the super class. If the transaction + * has not been started yet then the transaction is started before the + * runQuery call is made. + * + * @param {Query} query A Query object + * @param {object} [options] Optional configuration. + * @param {function} [callback] The callback function. If omitted, a readable + * stream instance is returned. + * + */ + runQuery(query: Query, options?: RunQueryOptions): Promise; + runQuery( + query: Query, + options: RunQueryOptions, + callback: RunQueryCallback, + ): void; + runQuery(query: Query, callback: RunQueryCallback): void; + runQuery( + query: Query, + optionsOrCallback?: RunQueryOptions | RunQueryCallback, + cb?: RunQueryCallback, + ): void | Promise { + const options = + typeof optionsOrCallback === 'object' && optionsOrCallback + ? optionsOrCallback + : {}; + const callback = + typeof optionsOrCallback === 'function' ? optionsOrCallback : cb!; + // This ensures that the transaction is started before calling runQuery + this.#blockWithMutex(() => { + super.runQuery(query, options, callback); + }); + } + + /** + * Insert or update the specified object(s) in the current transaction. If a + * key is incomplete, its associated object is inserted and the original Key + * object is updated to contain the generated ID. + * + * This method will determine the correct Datastore method to execute + * (`upsert`, `insert`, or `update`) by using the key(s) provided. For + * example, if you provide an incomplete key (one without an ID), the request + * will create a new entity and have its ID automatically assigned. If you + * provide a complete key, the entity will be updated with the data specified. + * + * By default, all properties are indexed. To prevent a property from being + * included in *all* indexes, you must supply an `excludeFromIndexes` array. + * See below for an example. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the example below to + * see how to target properties at different levels of nesting within your + * entity. + * @param {object} entities.data Data to save with the provided key. + * + * @example + * ``` + * Save a single entity. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * + * // Notice that we are providing an incomplete key. After the transaction is + * // committed, the Key object held by the `key` variable will be populated + * // with a path containing its generated ID. + * //- + * const key = datastore.key('Company'); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.save({ + * key: key, + * data: { + * rating: '10' + * } + * }); + * + * transaction.commit((err) => { + * if (!err) { + * // Data saved successfully. + * } + * }); + * }); + * + * ``` + * @example + * ``` + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * + * // Use an array, `excludeFromIndexes`, to exclude properties from indexing. + * // This will allow storing string values larger than 1500 bytes. + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.save({ + * key: key, + * excludeFromIndexes: [ + * 'description', + * 'embeddedEntity.description', + * 'arrayValue[].description' + * ], + * data: { + * description: 'Long string (...)', + * embeddedEntity: { + * description: 'Long string (...)' + * }, + * arrayValue: [ + * { + * description: 'Long string (...)' + * } + * ] + * } + * }); + * + * transaction.commit((err) => { + * if (!err) { + * // Data saved successfully. + * } + * }); + * }); + * + * ``` + * @example + * ``` + * Save multiple entities at once. + * const {Datastore} = require('@google-cloud/datastore'); + * const datastore = new Datastore(); + * const transaction = datastore.transaction(); + * const companyKey = datastore.key(['Company', 123]); + * const productKey = datastore.key(['Product', 'Computer']); + * + * transaction.run((err) => { + * if (err) { + * // Error handling omitted. + * } + * + * transaction.save([ + * { + * key: companyKey, + * data: { + * HQ: 'Dallas, TX' + * } + * }, + * { + * key: productKey, + * data: { + * vendor: 'Dell' + * } + * } + * ]); + * + * transaction.commit((err) => { + * if (!err) { + * // Data saved successfully. + * } + * }); + * }); + * ``` + */ + save(entities: Entities): void { + arrify(entities).forEach((ent: Entity) => { + this.modifiedEntities_.push({ + entity: { + key: ent.key, + }, + method: 'save', + args: [ent], + }); + }); + } + + /** + * Maps to {@link https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/transaction#_google_cloud_datastore_Transaction_save_member_1_|Datastore#save}, forcing the method to be `update`. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entities.data Data to save with the provided key. + */ + update(entities: Entities): void { + entities = arrify(entities) + .map(DatastoreRequest.prepareEntityObject_) + .map((x: PrepareEntityObjectResponse) => { + x.method = 'update'; + return x; + }); + + this.save(entities); + } + + /** + * Maps to {@link https://cloud.google.com/nodejs/docs/reference/datastore/latest/datastore/transaction#_google_cloud_datastore_Transaction_save_member_1_|Datastore#save}, forcing the method to be `upsert`. + * + * @param {object|object[]} entities Datastore key object(s). + * @param {Key} entities.key Datastore key object. + * @param {string[]} [entities.excludeFromIndexes] Exclude properties from + * indexing using a simple JSON path notation. See the examples in + * {@link Datastore#save} to see how to target properties at different + * levels of nesting within your entity. + * @param {object} entities.data Data to save with the provided key. + */ + upsert(entities: Entities): void { + entities = arrify(entities) + .map(DatastoreRequest.prepareEntityObject_) + .map((x: PrepareEntityObjectResponse) => { + x.method = 'upsert'; + return x; + }); + + this.save(entities); + } + + /** + * Some rpc calls require that the transaction has been started (i.e, has a + * valid id) before they can be sent. #withBeginTransaction acts as a wrapper + * over those functions. + * + * If the transaction has not begun yet, `#withBeginTransaction` will first + * send an rpc to begin the transaction, and then execute the wrapped + * function. If it has begun, the wrapped function will be called directly + * instead. If an error is encountered during the beginTransaction call, the + * callback will be executed instead of the wrapped function. + * + * @param {CallOptions | undefined} [gaxOptions] Gax options provided by the + * user that are used for the beginTransaction grpc call. + * @param {function} [fn] A function which is run after ensuring a + * transaction has begun. + * @param {function} [callback] A callback provided by the user that expects + * an error in the first argument and a custom data type for the rest of the + * arguments. + * @private + */ + #withBeginTransaction( + gaxOptions: CallOptions | undefined, + fn: () => void, + callback: (...args: [Error | null, ...T] | [Error | null]) => void, + ): void { + (async () => { + if (this.state === TransactionState.NOT_STARTED) { + try { + await this.#mutex.runExclusive(async () => { + if (this.state === TransactionState.NOT_STARTED) { + // This sends an rpc call to get the transaction id + const runResults = await this.#beginTransactionAsync({ + gaxOptions, + }); + if (runResults.err) { + // The rpc getting the id was unsuccessful. + // Do not call the wrapped function. + throw runResults.err; + } + this.parseTransactionResponse(runResults.resp); + // The rpc saving the transaction id was successful. + // Now the wrapped function fn will be called. + } + }); + } catch (err: any) { + // Handle an error produced by the beginTransactionAsync call + return callback(err); + } + } + return fn(); + })().catch(err => { + throw err; + }); + } + + /* + * Some rpc calls require that the transaction has been started (i.e, has a + * valid id) before they can be sent. #withBeginTransaction acts as a wrapper + * over those functions. + * + * If the transaction has not begun yet, `#blockWithMutex` will call the + * wrapped function which will begin the transaction in the rpc call it sends. + * If the transaction has begun, the wrapped function will be called, but it + * will not begin a transaction. + * + * @param {function} [fn] A function which is run after ensuring a + * transaction has begun. + */ + #blockWithMutex(fn: () => void) { + (async () => { + if (this.state === TransactionState.NOT_STARTED) { + await this.#mutex.runExclusive(async () => { + fn(); + }); + } else { + fn(); + } + })().catch(err => { + throw err; + }); + } +} + +export type ModifiedEntities = Array<{ + entity: {key: Entity}; + method: string; + args: Entity[]; +}>; +export type RunResponse = [ + Transaction, + google.datastore.v1.IBeginTransactionResponse, +]; +export interface RunCallback { + ( + error: Error | null, + transaction: Transaction | null, + response?: google.datastore.v1.IBeginTransactionResponse, + ): void; +} +export interface RollbackCallback { + (error: Error | null, response?: google.datastore.v1.IRollbackResponse): void; +} +export type RollbackResponse = [google.datastore.v1.IRollbackResponse]; +export interface RunOptions { + readOnly?: boolean; + transactionId?: string; + transactionOptions?: TransactionOptions; + gaxOptions?: CallOptions; +} +/*! Developer Documentation + * + * All async methods (except for streams) will return a Promise in the event + * that a callback is omitted. + */ +promisifyAll(Transaction, { + exclude: [ + 'createAggregationQuery', + 'createQuery', + 'delete', + 'insert', + '#runAsync', + 'save', + 'update', + 'upsert', + ], +}); + +/** + * Reference to the {@link Transaction} class. + * @name module:@google-cloud/datastore.Transaction + * @see Transaction + */ +export {Transaction}; diff --git a/handwritten/nodejs-datastore/src/utils/entity/buildEntityProto.ts b/handwritten/nodejs-datastore/src/utils/entity/buildEntityProto.ts new file mode 100644 index 00000000000..a334d8b47ba --- /dev/null +++ b/handwritten/nodejs-datastore/src/utils/entity/buildEntityProto.ts @@ -0,0 +1,60 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {entity, Entity, EntityProto, ValueProto} from '../../entity'; +import {EntityProtoReduceAccumulator, EntityProtoReduceData} from '../../index'; +import addExcludeFromIndexes = entity.addExcludeFromIndexes; + +/** + * This function builds the entity proto from the entity object. We cannot + * rely on entity.entityToEntityProto for this because this function is only + * designed to be used for non-array entities. + * + */ +export function buildEntityProto(entityObject: Entity) { + let entityProto: EntityProto = {}; + if (Array.isArray(entityObject.data)) { + // This code builds the right entityProto from the entityObject + entityProto.properties = entityObject.data.reduce( + (acc: EntityProtoReduceAccumulator, data: EntityProtoReduceData) => { + const value = entity.encodeValue(data.value, data.name.toString()); + + if (typeof data.excludeFromIndexes === 'boolean') { + const excluded = data.excludeFromIndexes; + let values = value.arrayValue && value.arrayValue.values; + + if (values) { + values = values.map((x: ValueProto) => { + x.excludeFromIndexes = excluded; + return x; + }); + } else { + value.excludeFromIndexes = data.excludeFromIndexes; + } + } + + acc[data.name] = value; + + return acc; + }, + {}, + ); + // This code adds excludeFromIndexes in the right places + addExcludeFromIndexes(entityObject.excludeFromIndexes, entityProto); + } else { + // This code builds the right entityProto from the entityObject + entityProto = entity.entityToEntityProto(entityObject); + } + return entityProto; +} diff --git a/handwritten/nodejs-datastore/src/utils/entity/buildPropertyTransforms.ts b/handwritten/nodejs-datastore/src/utils/entity/buildPropertyTransforms.ts new file mode 100644 index 00000000000..333d4bd5363 --- /dev/null +++ b/handwritten/nodejs-datastore/src/utils/entity/buildPropertyTransforms.ts @@ -0,0 +1,73 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {entity, PropertyTransform} from '../../entity'; +import {google} from '../../../protos/protos'; +import IValue = google.datastore.v1.IValue; +import ServerValue = google.datastore.v1.PropertyTransform.ServerValue; + +/** + * This method takes the user supplied transforms object and returns a list of + * corresponding transforms that are instead in the shape of the protos so that + * they can be included in the grpc request to the service directly. + * + * @param transforms The transforms supplied by the user that the user intends + * to apply. + */ +export function buildPropertyTransforms(transforms: PropertyTransform[]) { + const propertyTransforms: google.datastore.v1.IPropertyTransform[] = []; + transforms.forEach((transform: PropertyTransform) => { + const property = transform.property; + // If the user's transform has a setToServerValue property then ensure the + // propertyTransforms sent in the request have a setToServerValue transform. + if (transform.setToServerValue) { + propertyTransforms.push({ + property, + setToServerValue: ServerValue.REQUEST_TIME, + }); + } + // If the transform has an 'increment', 'maximum' or 'minimum' property then + // add the corresponding property transform to the propertyTransforms in the + // request. + ['increment', 'maximum', 'minimum'].forEach(type => { + const castedType = type as 'increment' | 'maximum' | 'minimum'; + if (transform[castedType]) { + propertyTransforms.push({ + property, + [castedType]: entity.encodeValue( + parseFloat(transform[castedType]), + property, + ) as IValue, + }); + } + }); + // If the transform has an 'appendMissingElements' or 'removeAllFromArray' + // property then add the corresponding property transform to the + // propertyTransforms in the request. + ['appendMissingElements', 'removeAllFromArray'].forEach(type => { + const castedType = type as 'appendMissingElements' | 'removeAllFromArray'; + if (transform[castedType]) { + propertyTransforms.push({ + property, + [castedType]: { + values: transform[castedType].map(element => { + return entity.encodeValue(element, property) as IValue; + }), + }, + }); + } + }); + }); + return propertyTransforms; +} diff --git a/handwritten/nodejs-datastore/src/utils/entity/extendExcludeFromIndexes.ts b/handwritten/nodejs-datastore/src/utils/entity/extendExcludeFromIndexes.ts new file mode 100644 index 00000000000..3f3787f9e42 --- /dev/null +++ b/handwritten/nodejs-datastore/src/utils/entity/extendExcludeFromIndexes.ts @@ -0,0 +1,52 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {entity, Entity} from '../../entity'; + +/** + * This function extends the excludeFromIndexes list when it finds + * large properties in the entity object. The extended excludeFromIndexes + * list is then used when building the entity proto. + * + * @param {Entity} entityObject The entity object to parse for properties to + * add to the excludeFromIndexes list. + */ +export function extendExcludeFromIndexes(entityObject: Entity) { + if (entityObject.excludeLargeProperties) { + if (Array.isArray(entityObject.data)) { + // This code populates the excludeFromIndexes list with the right values. + entityObject.data.forEach( + (data: { + name: { + toString(): string; + }; + value: Entity; + excludeFromIndexes?: boolean; + }) => { + entityObject.excludeFromIndexes = entity.findLargeProperties_( + data.value, + data.name.toString(), + entityObject.excludeFromIndexes, + ); + }, + ); + } else { + entityObject.excludeFromIndexes = entity.findLargeProperties_( + entityObject.data, + '', + entityObject.excludeFromIndexes, + ); + } + } +} diff --git a/handwritten/nodejs-datastore/src/v1/datastore_admin_client.ts b/handwritten/nodejs-datastore/src/v1/datastore_admin_client.ts new file mode 100644 index 00000000000..1156724c081 --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/datastore_admin_client.ts @@ -0,0 +1,1852 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, +} from 'google-gax'; +import {Transform} from 'stream'; +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; + +/** + * Client JSON configuration object, loaded from + * `src/v1/datastore_admin_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './datastore_admin_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Google Cloud Datastore Admin API + * + * The Datastore Admin API provides several admin services for Cloud Datastore. + * + * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud + * Datastore API. + * + * Operation: An Operation represents work being performed in the background. + * + * EntityFilter: Allows specifying a subset of entities in a project. This is + * specified as a combination of kinds and namespaces (either or both of which + * may be all). + * + * Export/Import Service: + * + * - The Export/Import service provides the ability to copy all or a subset of + * entities to/from Google Cloud Storage. + * - Exported data may be imported into Cloud Datastore for any Google Cloud + * Platform project. It is not restricted to the export source project. It is + * possible to export from one project and then import into another. + * - Exported data can also be loaded into Google BigQuery for analysis. + * - Exports and imports are performed asynchronously. An Operation resource is + * created for each export/import. The state (including any errors encountered) + * of the export/import may be queried via the Operation resource. + * + * Index Service: + * + * - The index service manages Cloud Datastore composite indexes. + * - Index creation and deletion are 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. + * + * Operation Service: + * + * - 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 not yet done may be cancelled. The request to cancel + * is asynchronous and the operation may continue to run for some time after the + * request to cancel is made. + * - An operation that is done may be deleted so that it is no longer listed as + * part of the Operation collection. + * - ListOperations returns all pending operations, but not completed + * operations. + * - Operations are created by service DatastoreAdmin, but are accessed via + * service google.longrunning.Operations. + * @class + * @memberof v1 + */ +export class DatastoreAdminClient { + 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}; + private _universeDomain: string; + private _servicePath: string; + private _log = logging.log('datastore-admin'); + + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + operationsClient: gax.OperationsClient; + datastoreAdminStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DatastoreAdminClient. + * + * @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://cloud.google.com/docs/authentication/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 DatastoreAdminClient({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 DatastoreAdminClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); + } + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; + this._servicePath = 'datastore.' + this._universeDomain; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._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 !== this._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 = this._servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === this._servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process === 'object' && '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 = { + listIndexes: new this._gaxModule.PageDescriptor( + 'pageToken', + 'nextPageToken', + 'indexes', + ), + }; + + 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/*/operations/*}:cancel', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*}/operations', + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + const exportEntitiesResponse = protoFilesRoot.lookup( + '.google.datastore.admin.v1.ExportEntitiesResponse', + ) as gax.protobuf.Type; + const exportEntitiesMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.ExportEntitiesMetadata', + ) as gax.protobuf.Type; + const importEntitiesResponse = protoFilesRoot.lookup( + '.google.protobuf.Empty', + ) as gax.protobuf.Type; + const importEntitiesMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.ImportEntitiesMetadata', + ) as gax.protobuf.Type; + const createIndexResponse = protoFilesRoot.lookup( + '.google.datastore.admin.v1.Index', + ) as gax.protobuf.Type; + const createIndexMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.IndexOperationMetadata', + ) as gax.protobuf.Type; + const deleteIndexResponse = protoFilesRoot.lookup( + '.google.datastore.admin.v1.Index', + ) as gax.protobuf.Type; + const deleteIndexMetadata = protoFilesRoot.lookup( + '.google.datastore.admin.v1.IndexOperationMetadata', + ) as gax.protobuf.Type; + + this.descriptors.longrunning = { + exportEntities: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + exportEntitiesResponse.decode.bind(exportEntitiesResponse), + exportEntitiesMetadata.decode.bind(exportEntitiesMetadata), + ), + importEntities: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + importEntitiesResponse.decode.bind(importEntitiesResponse), + importEntitiesMetadata.decode.bind(importEntitiesMetadata), + ), + createIndex: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + createIndexResponse.decode.bind(createIndexResponse), + createIndexMetadata.decode.bind(createIndexMetadata), + ), + deleteIndex: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + deleteIndexResponse.decode.bind(deleteIndexResponse), + deleteIndexMetadata.decode.bind(deleteIndexMetadata), + ), + }; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.datastore.admin.v1.DatastoreAdmin', + 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.datastoreAdminStub) { + return this.datastoreAdminStub; + } + + // Put together the "service stub" for + // google.datastore.admin.v1.DatastoreAdmin. + this.datastoreAdminStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.datastore.admin.v1.DatastoreAdmin', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.datastore.admin.v1.DatastoreAdmin, + 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 datastoreAdminStubMethods = [ + 'exportEntities', + 'importEntities', + 'createIndex', + 'deleteIndex', + 'getIndex', + 'listIndexes', + ]; + for (const methodName of datastoreAdminStubMethods) { + const callPromise = this.datastoreAdminStub.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.datastoreAdminStub; + } + + /** + * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); + } + return 'datastore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); + } + return 'datastore.googleapis.com'; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + + /** + * 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 an index. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.indexId + * The resource ID of the index to get. + * @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.datastore.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/datastore_admin.get_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_GetIndex_async + */ + getIndex( + request?: protos.google.datastore.admin.v1.IGetIndexRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest | undefined, + {} | undefined, + ] + >; + getIndex( + request: protos.google.datastore.admin.v1.IGetIndexRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, + {} | null | undefined + >, + ): void; + getIndex( + request: protos.google.datastore.admin.v1.IGetIndexRequest, + callback: Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, + {} | null | undefined + >, + ): void; + getIndex( + request?: protos.google.datastore.admin.v1.IGetIndexRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.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({ + project_id: request.projectId ?? '', + index_id: request.indexId ?? '', + }); + this.initialize().catch(err => { + throw err; + }); + this._log.info('getIndex request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('getIndex response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .getIndex(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IGetIndexRequest | undefined, + {} | undefined, + ]) => { + this._log.info('getIndex response %j', response); + return [response, options, rawResponse]; + }, + ); + } + + /** + * Exports a copy of all or a subset of entities from Google Cloud Datastore + * to another storage system, such as Google Cloud Storage. Recent updates to + * entities 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. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. Project ID against which to make the request. + * @param {number[]} request.labels + * Client-assigned labels. + * @param {google.datastore.admin.v1.EntityFilter} request.entityFilter + * Description of what data from the project is included in the export. + * @param {string} request.outputUrlPrefix + * Required. Location for the export metadata and data files. + * + * The full resource URL of the external storage location. Currently, only + * Google Cloud Storage is supported. So output_url_prefix should be of the + * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the + * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud + * Storage namespace path (this is not a Cloud Datastore namespace). For more + * information about Cloud Storage namespace paths, see + * [Object name + * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + * + * The resulting files will be nested deeper than the specified URL prefix. + * The final output URL will be provided in the + * {@link protos.google.datastore.admin.v1.ExportEntitiesResponse.output_url|google.datastore.admin.v1.ExportEntitiesResponse.output_url} + * field. That value should be used for subsequent ImportEntities operations. + * + * By nesting the data files deeper, the same Cloud Storage bucket can be used + * in multiple ExportEntities operations without conflict. + * @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/datastore_admin.export_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async + */ + exportEntities( + request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + exportEntities( + request: protos.google.datastore.admin.v1.IExportEntitiesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + exportEntities( + request: protos.google.datastore.admin.v1.IExportEntitiesRequest, + callback: Callback< + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + exportEntities( + request?: protos.google.datastore.admin.v1.IExportEntitiesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + 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({ + project_id: request.projectId ?? '', + }); + this.initialize().catch(err => { + throw err; + }); + const wrappedCallback: + | Callback< + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('exportEntities response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('exportEntities request %j', request); + return this.innerApiCalls + .exportEntities(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('exportEntities response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); + } + /** + * Check the status of the long running operation returned by `exportEntities()`. + * @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/datastore_admin.export_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ExportEntities_async + */ + async checkExportEntitiesProgress( + name: string, + ): Promise< + LROperation< + protos.google.datastore.admin.v1.ExportEntitiesResponse, + protos.google.datastore.admin.v1.ExportEntitiesMetadata + > + > { + this._log.info('exportEntities long-running'); + 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.exportEntities, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.datastore.admin.v1.ExportEntitiesResponse, + protos.google.datastore.admin.v1.ExportEntitiesMetadata + >; + } + /** + * Imports entities into Google Cloud Datastore. Existing entities with the + * same key 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 ImportEntities operation is cancelled, it is possible + * that a subset of the data has already been imported to Cloud Datastore. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. Project ID against which to make the request. + * @param {number[]} request.labels + * Client-assigned labels. + * @param {string} request.inputUrl + * Required. The full resource URL of the external storage location. + * Currently, only Google Cloud Storage is supported. So input_url should be + * of the form: + * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where + * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is + * an optional Cloud Storage namespace path (this is not a Cloud Datastore + * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written + * by the ExportEntities operation. For more information about Cloud Storage + * namespace paths, see + * [Object name + * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + * + * For more information, see + * {@link protos.google.datastore.admin.v1.ExportEntitiesResponse.output_url|google.datastore.admin.v1.ExportEntitiesResponse.output_url}. + * @param {google.datastore.admin.v1.EntityFilter} request.entityFilter + * Optionally specify which kinds/namespaces are to be imported. If provided, + * the list must be a subset of the EntityFilter used in creating the export, + * otherwise a FAILED_PRECONDITION error will be returned. If no filter is + * specified then all entities from the export are imported. + * @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/datastore_admin.import_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async + */ + importEntities( + request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + importEntities( + request: protos.google.datastore.admin.v1.IImportEntitiesRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + importEntities( + request: protos.google.datastore.admin.v1.IImportEntitiesRequest, + callback: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + importEntities( + request?: protos.google.datastore.admin.v1.IImportEntitiesRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + 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({ + project_id: request.projectId ?? '', + }); + this.initialize().catch(err => { + throw err; + }); + const wrappedCallback: + | Callback< + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('importEntities response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('importEntities request %j', request); + return this.innerApiCalls + .importEntities(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('importEntities response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); + } + /** + * Check the status of the long running operation returned by `importEntities()`. + * @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/datastore_admin.import_entities.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ImportEntities_async + */ + async checkImportEntitiesProgress( + name: string, + ): Promise< + LROperation< + protos.google.protobuf.Empty, + protos.google.datastore.admin.v1.ImportEntitiesMetadata + > + > { + this._log.info('importEntities long-running'); + 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.importEntities, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.protobuf.Empty, + protos.google.datastore.admin.v1.ImportEntitiesMetadata + >; + } + /** + * Creates the specified index. + * A newly created index's initial state is `CREATING`. On completion of the + * returned {@link protos.google.longrunning.Operation|google.longrunning.Operation}, the + * state will be `READY`. If the index already exists, the call will return an + * `ALREADY_EXISTS` status. + * + * During index creation, the process could result in an error, in which + * case the index will move to the `ERROR` state. The process can be recovered + * by fixing the data that caused the error, removing the index with + * {@link protos.google.datastore.admin.v1.DatastoreAdmin.DeleteIndex|delete}, then + * re-creating the index with [create] + * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + * + * Indexes with a single property cannot be created. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {google.datastore.admin.v1.Index} request.index + * The index to create. The name and state fields are output only and will be + * ignored. Single property indexes cannot be created or deleted. + * @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/datastore_admin.create_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async + */ + createIndex( + request?: protos.google.datastore.admin.v1.ICreateIndexRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + createIndex( + request: protos.google.datastore.admin.v1.ICreateIndexRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createIndex( + request: protos.google.datastore.admin.v1.ICreateIndexRequest, + callback: Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + createIndex( + request?: protos.google.datastore.admin.v1.ICreateIndexRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + 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({ + project_id: request.projectId ?? '', + }); + this.initialize().catch(err => { + throw err; + }); + const wrappedCallback: + | Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('createIndex response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('createIndex request %j', request); + return this.innerApiCalls + .createIndex(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('createIndex response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); + } + /** + * 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/datastore_admin.create_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_CreateIndex_async + */ + async checkCreateIndexProgress( + name: string, + ): Promise< + LROperation< + protos.google.datastore.admin.v1.Index, + protos.google.datastore.admin.v1.IndexOperationMetadata + > + > { + this._log.info('createIndex long-running'); + 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< + protos.google.datastore.admin.v1.Index, + protos.google.datastore.admin.v1.IndexOperationMetadata + >; + } + /** + * Deletes an existing index. + * An index can only be deleted if it is in a `READY` or `ERROR` state. On + * successful execution of the request, the index will be in a `DELETING` + * {@link protos.google.datastore.admin.v1.Index.State|state}. And on completion of the + * returned {@link protos.google.longrunning.Operation|google.longrunning.Operation}, the + * index will be removed. + * + * During index deletion, the process could result in an error, in which + * case the index will move to the `ERROR` state. The process can be recovered + * by fixing the data that caused the error, followed by calling + * {@link protos.google.datastore.admin.v1.DatastoreAdmin.DeleteIndex|delete} again. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.indexId + * The resource ID of the index to delete. + * @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/datastore_admin.delete_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async + */ + deleteIndex( + request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, + options?: CallOptions, + ): Promise< + [ + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ] + >; + deleteIndex( + request: protos.google.datastore.admin.v1.IDeleteIndexRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + deleteIndex( + request: protos.google.datastore.admin.v1.IDeleteIndexRequest, + callback: Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): void; + deleteIndex( + request?: protos.google.datastore.admin.v1.IDeleteIndexRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + 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({ + project_id: request.projectId ?? '', + index_id: request.indexId ?? '', + }); + this.initialize().catch(err => { + throw err; + }); + const wrappedCallback: + | Callback< + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, rawResponse, _) => { + this._log.info('deleteIndex response %j', rawResponse); + callback!(error, response, rawResponse, _); // We verified callback above. + } + : undefined; + this._log.info('deleteIndex request %j', request); + return this.innerApiCalls + .deleteIndex(request, options, wrappedCallback) + ?.then( + ([response, rawResponse, _]: [ + LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined, + ]) => { + this._log.info('deleteIndex response %j', rawResponse); + return [response, rawResponse, _]; + }, + ); + } + /** + * Check the status of the long running operation returned by `deleteIndex()`. + * @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/datastore_admin.delete_index.js + * region_tag:datastore_v1_generated_DatastoreAdmin_DeleteIndex_async + */ + async checkDeleteIndexProgress( + name: string, + ): Promise< + LROperation< + protos.google.datastore.admin.v1.Index, + protos.google.datastore.admin.v1.IndexOperationMetadata + > + > { + this._log.info('deleteIndex long-running'); + 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.deleteIndex, + this._gaxModule.createDefaultBackoffSettings(), + ); + return decodeOperation as LROperation< + protos.google.datastore.admin.v1.Index, + protos.google.datastore.admin.v1.IndexOperationMetadata + >; + } + /** + * Lists the indexes that match the specified filters. Datastore uses an + * eventually consistent query to fetch the list of indexes and may + * occasionally return stale results. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.filter + * @param {number} request.pageSize + * The maximum number of items to return. If zero, then all results will be + * returned. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @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.datastore.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.datastore.admin.v1.IListIndexesRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.admin.v1.IIndex[], + protos.google.datastore.admin.v1.IListIndexesRequest | null, + protos.google.datastore.admin.v1.IListIndexesResponse, + ] + >; + listIndexes( + request: protos.google.datastore.admin.v1.IListIndexesRequest, + options: CallOptions, + callback: PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, + protos.google.datastore.admin.v1.IIndex + >, + ): void; + listIndexes( + request: protos.google.datastore.admin.v1.IListIndexesRequest, + callback: PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, + protos.google.datastore.admin.v1.IIndex + >, + ): void; + listIndexes( + request?: protos.google.datastore.admin.v1.IListIndexesRequest, + optionsOrCallback?: + | CallOptions + | PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + | protos.google.datastore.admin.v1.IListIndexesResponse + | null + | undefined, + protos.google.datastore.admin.v1.IIndex + >, + callback?: PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + protos.google.datastore.admin.v1.IListIndexesResponse | null | undefined, + protos.google.datastore.admin.v1.IIndex + >, + ): Promise< + [ + protos.google.datastore.admin.v1.IIndex[], + protos.google.datastore.admin.v1.IListIndexesRequest | null, + protos.google.datastore.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({ + project_id: request.projectId ?? '', + }); + this.initialize().catch(err => { + throw err; + }); + const wrappedCallback: + | PaginationCallback< + protos.google.datastore.admin.v1.IListIndexesRequest, + | protos.google.datastore.admin.v1.IListIndexesResponse + | null + | undefined, + protos.google.datastore.admin.v1.IIndex + > + | undefined = callback + ? (error, values, nextPageRequest, rawResponse) => { + this._log.info('listIndexes values %j', values); + callback!(error, values, nextPageRequest, rawResponse); // We verified callback above. + } + : undefined; + this._log.info('listIndexes request %j', request); + return this.innerApiCalls + .listIndexes(request, options, wrappedCallback) + ?.then( + ([response, input, output]: [ + protos.google.datastore.admin.v1.IIndex[], + protos.google.datastore.admin.v1.IListIndexesRequest | null, + protos.google.datastore.admin.v1.IListIndexesResponse, + ]) => { + this._log.info('listIndexes values %j', response); + return [response, input, output]; + }, + ); + } + + /** + * Equivalent to `listIndexes`, but returns a NodeJS Stream object. + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Project ID against which to make the request. + * @param {string} request.filter + * @param {number} request.pageSize + * The maximum number of items to return. If zero, then all results will be + * returned. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @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.datastore.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.datastore.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({ + project_id: request.projectId ?? '', + }); + const defaultCallSettings = this._defaults['listIndexes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => { + throw err; + }); + this._log.info('listIndexes stream %j', request); + 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.projectId + * Project ID against which to make the request. + * @param {string} request.filter + * @param {number} request.pageSize + * The maximum number of items to return. If zero, then all results will be + * returned. + * @param {string} request.pageToken + * The next_page_token value returned from a previous List request, if any. + * @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.datastore.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/datastore_admin.list_indexes.js + * region_tag:datastore_v1_generated_DatastoreAdmin_ListIndexes_async + */ + listIndexesAsync( + request?: protos.google.datastore.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({ + project_id: request.projectId ?? '', + }); + const defaultCallSettings = this._defaults['listIndexes']; + const callSettings = defaultCallSettings.merge(options); + this.initialize().catch(err => { + throw err; + }); + this._log.info('listIndexes iterate %j', request); + return this.descriptors.page.listIndexes.asyncIterate( + this.innerApiCalls['listIndexes'] as GaxCall, + request as {}, + callSettings, + ) as AsyncIterable; + } + /** + * 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, + optionsOrCallback?: + | 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]> { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + 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 { + 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 ?? '', + }); + 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, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + >, + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + 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, + optionsOrCallback?: + | 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 { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + return this.operationsClient.deleteOperation(request, options, callback); + } + + /** + * 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.datastoreAdminStub && !this._terminated) { + return this.datastoreAdminStub.then(stub => { + this._log.info('ending gRPC channel'); + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/handwritten/nodejs-datastore/src/v1/datastore_admin_client_config.json b/handwritten/nodejs-datastore/src/v1/datastore_admin_client_config.json new file mode 100644 index 00000000000..9dbc3f5fff3 --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/datastore_admin_client_config.json @@ -0,0 +1,56 @@ +{ + "interfaces": { + "google.datastore.admin.v1.DatastoreAdmin": { + "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": { + "ExportEntities": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ImportEntities": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "CreateIndex": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "DeleteIndex": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "GetIndex": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "ListIndexes": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/handwritten/nodejs-datastore/src/v1/datastore_admin_proto_list.json b/handwritten/nodejs-datastore/src/v1/datastore_admin_proto_list.json new file mode 100644 index 00000000000..7a038c3a12f --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/datastore_admin_proto_list.json @@ -0,0 +1,5 @@ +[ + "../../protos/google/datastore/admin/v1/datastore_admin.proto", + "../../protos/google/datastore/admin/v1/index.proto", + "../../protos/google/datastore/admin/v1/migration.proto" +] diff --git a/handwritten/nodejs-datastore/src/v1/datastore_client.ts b/handwritten/nodejs-datastore/src/v1/datastore_client.ts new file mode 100644 index 00000000000..1b1158315ea --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/datastore_client.ts @@ -0,0 +1,1806 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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, +} from 'google-gax'; + +import * as protos from '../../protos/protos'; +import jsonProtos = require('../../protos/protos.json'); +import {loggingUtils as logging} from 'google-gax'; + +/** + * Client JSON configuration object, loaded from + * `src/v1/datastore_client_config.json`. + * This file defines retry strategy and timeouts for all API methods in this library. + */ +import * as gapicConfig from './datastore_client_config.json'; +const version = require('../../../package.json').version; + +/** + * Each RPC normalizes the partition IDs of the keys in its input entities, + * and always returns entities with keys with normalized partition IDs. + * This applies to all keys and entities, including those in values, except keys + * with both an empty path and an empty or unset partition ID. Normalization of + * input keys sets the project ID (if not already set) to the project ID from + * the request. + * + * @class + * @memberof v1 + */ +export class DatastoreClient { + 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}; + private _universeDomain: string; + private _servicePath: string; + private _log = logging.log('datastore'); + + auth: gax.GoogleAuth; + descriptors: Descriptors = { + page: {}, + stream: {}, + longrunning: {}, + batching: {}, + }; + warn: (code: string, message: string, warnType?: string) => void; + innerApiCalls: {[name: string]: Function}; + operationsClient: gax.OperationsClient; + datastoreStub?: Promise<{[name: string]: Function}>; + + /** + * Construct an instance of DatastoreClient. + * + * @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://cloud.google.com/docs/authentication/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 DatastoreClient({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 DatastoreClient; + if ( + opts?.universe_domain && + opts?.universeDomain && + opts?.universe_domain !== opts?.universeDomain + ) { + throw new Error( + 'Please set either universe_domain or universeDomain, but not both.', + ); + } + const universeDomainEnvVar = + typeof process === 'object' && typeof process.env === 'object' + ? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] + : undefined; + this._universeDomain = + opts?.universeDomain ?? + opts?.universe_domain ?? + universeDomainEnvVar ?? + 'googleapis.com'; + this._servicePath = 'datastore.' + this._universeDomain; + const servicePath = + opts?.servicePath || opts?.apiEndpoint || this._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 !== this._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 = this._servicePath; + + // Set the default scopes in auth client if needed. + if (servicePath === this._servicePath) { + this.auth.defaultScopes = staticMembers.scopes; + } + + // Determine the client header string. + const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`]; + if (typeof process === 'object' && '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); + + 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/*/operations/*}:cancel', + }, + { + selector: 'google.longrunning.Operations.DeleteOperation', + delete: '/v1/{name=projects/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.GetOperation', + get: '/v1/{name=projects/*/operations/*}', + }, + { + selector: 'google.longrunning.Operations.ListOperations', + get: '/v1/{name=projects/*}/operations', + }, + ]; + } + this.operationsClient = this._gaxModule + .lro(lroOptions) + .operationsClient(opts); + + this.descriptors.longrunning = {}; + + // Put together the default options sent with requests. + this._defaults = this._gaxGrpc.constructSettings( + 'google.datastore.v1.Datastore', + 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.datastoreStub) { + return this.datastoreStub; + } + + // Put together the "service stub" for + // google.datastore.v1.Datastore. + this.datastoreStub = this._gaxGrpc.createStub( + this._opts.fallback + ? (this._protos as protobuf.Root).lookupService( + 'google.datastore.v1.Datastore', + ) + : // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this._protos as any).google.datastore.v1.Datastore, + 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 datastoreStubMethods = [ + 'lookup', + 'runQuery', + 'runAggregationQuery', + 'beginTransaction', + 'commit', + 'rollback', + 'allocateIds', + 'reserveIds', + ]; + for (const methodName of datastoreStubMethods) { + const callPromise = this.datastoreStub.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 = undefined; + const apiCall = this._gaxModule.createApiCall( + callPromise, + this._defaults[methodName], + descriptor, + this._opts.fallback, + ); + + this.innerApiCalls[methodName] = apiCall; + } + + return this.datastoreStub; + } + + /** + * The DNS address for this API service. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get servicePath() { + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static servicePath is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); + } + return 'datastore.googleapis.com'; + } + + /** + * The DNS address for this API service - same as servicePath. + * @deprecated Use the apiEndpoint method of the client instance. + * @returns {string} The DNS address for this service. + */ + static get apiEndpoint() { + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + process.emitWarning( + 'Static apiEndpoint is deprecated, please use the instance method instead.', + 'DeprecationWarning', + ); + } + return 'datastore.googleapis.com'; + } + + /** + * The DNS address for this API service. + * @returns {string} The DNS address for this service. + */ + get apiEndpoint() { + return this._servicePath; + } + + get universeDomain() { + return this._universeDomain; + } + + /** + * 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 -- + // ------------------- + /** + * Looks up entities by key. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {google.datastore.v1.ReadOptions} request.readOptions + * The options for this lookup request. + * @param {number[]} request.keys + * Required. Keys of entities to look up. + * @param {google.datastore.v1.PropertyMask} request.propertyMask + * The properties to return. Defaults to returning all properties. + * + * If this field is set and an entity has a property not referenced in the + * mask, it will be absent from {@link protos.|LookupResponse.found.entity.properties}. + * + * The entity's key is always returned. + * @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.datastore.v1.LookupResponse|LookupResponse}. + * 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/datastore.lookup.js + * region_tag:datastore_v1_generated_Datastore_Lookup_async + */ + lookup( + request?: protos.google.datastore.v1.ILookupRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | undefined, + {} | undefined, + ] + >; + lookup( + request: protos.google.datastore.v1.ILookupRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | null | undefined, + {} | null | undefined + >, + ): void; + lookup( + request: protos.google.datastore.v1.ILookupRequest, + callback: Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | null | undefined, + {} | null | undefined + >, + ): void; + lookup( + request?: protos.google.datastore.v1.ILookupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | 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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('lookup request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('lookup response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .lookup(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | undefined, + {} | undefined, + ]) => { + this._log.info('lookup response %j', response); + return [response, options, rawResponse]; + }, + ); + } + /** + * Queries for entities. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {google.datastore.v1.PartitionId} request.partitionId + * Entities are partitioned into subsets, identified by a partition ID. + * Queries are scoped to a single partition. + * This partition ID is normalized with the standard default context + * partition ID. + * @param {google.datastore.v1.ReadOptions} request.readOptions + * The options for this query. + * @param {google.datastore.v1.Query} request.query + * The query to run. + * @param {google.datastore.v1.GqlQuery} request.gqlQuery + * The GQL query to run. This query must be a non-aggregation query. + * @param {google.datastore.v1.PropertyMask} request.propertyMask + * The properties to return. + * This field must not be set for a projection query. + * + * See + * {@link protos.google.datastore.v1.LookupRequest.property_mask|LookupRequest.property_mask}. + * @param {google.datastore.v1.ExplainOptions} [request.explainOptions] + * Optional. Explain options for the query. If set, additional query + * statistics will be returned. If not, only query results will be returned. + * @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.datastore.v1.RunQueryResponse|RunQueryResponse}. + * 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/datastore.run_query.js + * region_tag:datastore_v1_generated_Datastore_RunQuery_async + */ + runQuery( + request?: protos.google.datastore.v1.IRunQueryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | undefined, + {} | undefined, + ] + >; + runQuery( + request: protos.google.datastore.v1.IRunQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | null | undefined, + {} | null | undefined + >, + ): void; + runQuery( + request: protos.google.datastore.v1.IRunQueryRequest, + callback: Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | null | undefined, + {} | null | undefined + >, + ): void; + runQuery( + request?: protos.google.datastore.v1.IRunQueryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | 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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('runQuery request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('runQuery response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .runQuery(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.IRunQueryResponse, + protos.google.datastore.v1.IRunQueryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('runQuery response %j', response); + return [response, options, rawResponse]; + }, + ); + } + /** + * Runs an aggregation query. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {google.datastore.v1.PartitionId} request.partitionId + * Entities are partitioned into subsets, identified by a partition ID. + * Queries are scoped to a single partition. + * This partition ID is normalized with the standard default context + * partition ID. + * @param {google.datastore.v1.ReadOptions} request.readOptions + * The options for this query. + * @param {google.datastore.v1.AggregationQuery} request.aggregationQuery + * The query to run. + * @param {google.datastore.v1.GqlQuery} request.gqlQuery + * The GQL query to run. This query must be an aggregation query. + * @param {google.datastore.v1.ExplainOptions} [request.explainOptions] + * Optional. Explain options for the query. If set, additional query + * statistics will be returned. If not, only query results will be returned. + * @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.datastore.v1.RunAggregationQueryResponse|RunAggregationQueryResponse}. + * 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/datastore.run_aggregation_query.js + * region_tag:datastore_v1_generated_Datastore_RunAggregationQuery_async + */ + runAggregationQuery( + request?: protos.google.datastore.v1.IRunAggregationQueryRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.IRunAggregationQueryResponse, + protos.google.datastore.v1.IRunAggregationQueryRequest | undefined, + {} | undefined, + ] + >; + runAggregationQuery( + request: protos.google.datastore.v1.IRunAggregationQueryRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IRunAggregationQueryResponse, + protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, + {} | null | undefined + >, + ): void; + runAggregationQuery( + request: protos.google.datastore.v1.IRunAggregationQueryRequest, + callback: Callback< + protos.google.datastore.v1.IRunAggregationQueryResponse, + protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, + {} | null | undefined + >, + ): void; + runAggregationQuery( + request?: protos.google.datastore.v1.IRunAggregationQueryRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.IRunAggregationQueryResponse, + | protos.google.datastore.v1.IRunAggregationQueryRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.IRunAggregationQueryResponse, + protos.google.datastore.v1.IRunAggregationQueryRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.IRunAggregationQueryResponse, + protos.google.datastore.v1.IRunAggregationQueryRequest | 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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('runAggregationQuery request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.IRunAggregationQueryResponse, + | protos.google.datastore.v1.IRunAggregationQueryRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('runAggregationQuery response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .runAggregationQuery(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.IRunAggregationQueryResponse, + protos.google.datastore.v1.IRunAggregationQueryRequest | undefined, + {} | undefined, + ]) => { + this._log.info('runAggregationQuery response %j', response); + return [response, options, rawResponse]; + }, + ); + } + /** + * Begins a new transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {google.datastore.v1.TransactionOptions} request.transactionOptions + * Options for a new 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.datastore.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/datastore.begin_transaction.js + * region_tag:datastore_v1_generated_Datastore_BeginTransaction_async + */ + beginTransaction( + request?: protos.google.datastore.v1.IBeginTransactionRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest | undefined, + {} | undefined, + ] + >; + beginTransaction( + request: protos.google.datastore.v1.IBeginTransactionRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, + {} | null | undefined + >, + ): void; + beginTransaction( + request: protos.google.datastore.v1.IBeginTransactionRequest, + callback: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, + {} | null | undefined + >, + ): void; + beginTransaction( + request?: protos.google.datastore.v1.IBeginTransactionRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + | protos.google.datastore.v1.IBeginTransactionRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('beginTransaction request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + | protos.google.datastore.v1.IBeginTransactionRequest + | null + | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('beginTransaction response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .beginTransaction(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.IBeginTransactionResponse, + protos.google.datastore.v1.IBeginTransactionRequest | undefined, + {} | undefined, + ]) => { + this._log.info('beginTransaction response %j', response); + return [response, options, rawResponse]; + }, + ); + } + /** + * Commits a transaction, optionally creating, deleting or modifying some + * entities. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {google.datastore.v1.CommitRequest.Mode} request.mode + * The type of commit to perform. Defaults to `TRANSACTIONAL`. + * @param {Buffer} request.transaction + * The identifier of the transaction associated with the commit. A + * transaction identifier is returned by a call to + * {@link protos.google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. + * @param {google.datastore.v1.TransactionOptions} request.singleUseTransaction + * Options for beginning a new transaction for this request. + * The transaction is committed when the request completes. If specified, + * {@link protos.google.datastore.v1.TransactionOptions|TransactionOptions.mode} must be + * {@link protos.google.datastore.v1.TransactionOptions.ReadWrite|TransactionOptions.ReadWrite}. + * @param {number[]} request.mutations + * The mutations to perform. + * + * When mode is `TRANSACTIONAL`, mutations affecting a single entity are + * applied in order. The following sequences of mutations affecting a single + * entity are not permitted in a single `Commit` request: + * + * - `insert` followed by `insert` + * - `update` followed by `insert` + * - `upsert` followed by `insert` + * - `delete` followed by `update` + * + * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single + * entity. + * @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.datastore.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/datastore.commit.js + * region_tag:datastore_v1_generated_Datastore_Commit_async + */ + commit( + request?: protos.google.datastore.v1.ICommitRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest | undefined, + {} | undefined, + ] + >; + commit( + request: protos.google.datastore.v1.ICommitRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest | null | undefined, + {} | null | undefined + >, + ): void; + commit( + request: protos.google.datastore.v1.ICommitRequest, + callback: Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest | null | undefined, + {} | null | undefined + >, + ): void; + commit( + request?: protos.google.datastore.v1.ICommitRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('commit request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('commit response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .commit(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.ICommitResponse, + protos.google.datastore.v1.ICommitRequest | undefined, + {} | undefined, + ]) => { + this._log.info('commit response %j', response); + return [response, options, rawResponse]; + }, + ); + } + /** + * Rolls back a transaction. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {Buffer} request.transaction + * Required. The transaction identifier, returned by a call to + * {@link protos.google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. + * @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.datastore.v1.RollbackResponse|RollbackResponse}. + * 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/datastore.rollback.js + * region_tag:datastore_v1_generated_Datastore_Rollback_async + */ + rollback( + request?: protos.google.datastore.v1.IRollbackRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest | undefined, + {} | undefined, + ] + >; + rollback( + request: protos.google.datastore.v1.IRollbackRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest | null | undefined, + {} | null | undefined + >, + ): void; + rollback( + request: protos.google.datastore.v1.IRollbackRequest, + callback: Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest | null | undefined, + {} | null | undefined + >, + ): void; + rollback( + request?: protos.google.datastore.v1.IRollbackRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('rollback request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('rollback response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .rollback(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.IRollbackResponse, + protos.google.datastore.v1.IRollbackRequest | undefined, + {} | undefined, + ]) => { + this._log.info('rollback response %j', response); + return [response, options, rawResponse]; + }, + ); + } + /** + * Allocates IDs for the given keys, which is useful for referencing an entity + * before it is inserted. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {number[]} request.keys + * Required. A list of keys with incomplete key paths for which to allocate + * IDs. No key may be reserved/read-only. + * @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.datastore.v1.AllocateIdsResponse|AllocateIdsResponse}. + * 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/datastore.allocate_ids.js + * region_tag:datastore_v1_generated_Datastore_AllocateIds_async + */ + allocateIds( + request?: protos.google.datastore.v1.IAllocateIdsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | undefined, + {} | undefined, + ] + >; + allocateIds( + request: protos.google.datastore.v1.IAllocateIdsRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, + {} | null | undefined + >, + ): void; + allocateIds( + request: protos.google.datastore.v1.IAllocateIdsRequest, + callback: Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, + {} | null | undefined + >, + ): void; + allocateIds( + request?: protos.google.datastore.v1.IAllocateIdsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | 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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('allocateIds request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('allocateIds response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .allocateIds(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.IAllocateIdsResponse, + protos.google.datastore.v1.IAllocateIdsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('allocateIds response %j', response); + return [response, options, rawResponse]; + }, + ); + } + /** + * Prevents the supplied keys' IDs from being auto-allocated by Cloud + * Datastore. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.projectId + * Required. The ID of the project against which to make the request. + * @param {string} request.databaseId + * The ID of the database against which to make the request. + * + * '(default)' is not allowed; please use empty string '' to refer the default + * database. + * @param {number[]} request.keys + * Required. A list of keys with complete key paths whose numeric IDs should + * not be auto-allocated. + * @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.datastore.v1.ReserveIdsResponse|ReserveIdsResponse}. + * 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/datastore.reserve_ids.js + * region_tag:datastore_v1_generated_Datastore_ReserveIds_async + */ + reserveIds( + request?: protos.google.datastore.v1.IReserveIdsRequest, + options?: CallOptions, + ): Promise< + [ + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | undefined, + {} | undefined, + ] + >; + reserveIds( + request: protos.google.datastore.v1.IReserveIdsRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | null | undefined, + {} | null | undefined + >, + ): void; + reserveIds( + request: protos.google.datastore.v1.IReserveIdsRequest, + callback: Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | null | undefined, + {} | null | undefined + >, + ): void; + reserveIds( + request?: protos.google.datastore.v1.IReserveIdsRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | 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 || {}; + const routingParameter = {}; + { + const fieldValue = request.projectId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['project_id'] ?? fieldValue; + Object.assign(routingParameter, {project_id: parameterValue}); + } + } + } + { + const fieldValue = request.databaseId; + if (fieldValue !== undefined && fieldValue !== null) { + const match = fieldValue.toString().match(RegExp('(?.*)')); + if (match) { + const parameterValue = match.groups?.['database_id'] ?? fieldValue; + Object.assign(routingParameter, {database_id: parameterValue}); + } + } + } + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams(routingParameter); + this.initialize().catch(err => { + throw err; + }); + this._log.info('reserveIds request %j', request); + const wrappedCallback: + | Callback< + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | null | undefined, + {} | null | undefined + > + | undefined = callback + ? (error, response, options, rawResponse) => { + this._log.info('reserveIds response %j', response); + callback!(error, response, options, rawResponse); // We verified callback above. + } + : undefined; + return this.innerApiCalls + .reserveIds(request, options, wrappedCallback) + ?.then( + ([response, options, rawResponse]: [ + protos.google.datastore.v1.IReserveIdsResponse, + protos.google.datastore.v1.IReserveIdsRequest | undefined, + {} | undefined, + ]) => { + this._log.info('reserveIds response %j', response); + return [response, options, rawResponse]; + }, + ); + } + + /** + * 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, + optionsOrCallback?: + | 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]> { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + 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 { + 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 ?? '', + }); + 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, + optionsOrCallback?: + | gax.CallOptions + | Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + >, + callback?: Callback< + protos.google.longrunning.CancelOperationRequest, + protos.google.protobuf.Empty, + {} | undefined | null + >, + ): Promise { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + 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, + optionsOrCallback?: + | 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 { + let options: gax.CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as gax.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 ?? '', + }); + return this.operationsClient.deleteOperation(request, options, callback); + } + + /** + * 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.datastoreStub && !this._terminated) { + return this.datastoreStub.then(stub => { + this._log.info('ending gRPC channel'); + this._terminated = true; + stub.close(); + this.operationsClient.close(); + }); + } + return Promise.resolve(); + } +} diff --git a/handwritten/nodejs-datastore/src/v1/datastore_client_config.json b/handwritten/nodejs-datastore/src/v1/datastore_client_config.json new file mode 100644 index 00000000000..00d94ed6e47 --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/datastore_client_config.json @@ -0,0 +1,66 @@ +{ + "interfaces": { + "google.datastore.v1.Datastore": { + "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": { + "Lookup": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RunQuery": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "RunAggregationQuery": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + }, + "BeginTransaction": { + "timeout_millis": 60000, + "retry_codes_name": "non_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": "non_idempotent", + "retry_params_name": "default" + }, + "AllocateIds": { + "timeout_millis": 60000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, + "ReserveIds": { + "timeout_millis": 60000, + "retry_codes_name": "idempotent", + "retry_params_name": "default" + } + } + } + } +} diff --git a/handwritten/nodejs-datastore/src/v1/datastore_proto_list.json b/handwritten/nodejs-datastore/src/v1/datastore_proto_list.json new file mode 100644 index 00000000000..9bbbda2f942 --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/datastore_proto_list.json @@ -0,0 +1,7 @@ +[ + "../../protos/google/datastore/v1/aggregation_result.proto", + "../../protos/google/datastore/v1/datastore.proto", + "../../protos/google/datastore/v1/entity.proto", + "../../protos/google/datastore/v1/query.proto", + "../../protos/google/datastore/v1/query_profile.proto" +] diff --git a/handwritten/nodejs-datastore/src/v1/gapic_metadata.json b/handwritten/nodejs-datastore/src/v1/gapic_metadata.json new file mode 100644 index 00000000000..2b53e796b47 --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/gapic_metadata.json @@ -0,0 +1,87 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "typescript", + "protoPackage": "google.datastore.admin.v1", + "libraryPackage": "@google-cloud/datastore-admin", + "services": { + "DatastoreAdmin": { + "clients": { + "grpc": { + "libraryClient": "DatastoreAdminClient", + "rpcs": { + "GetIndex": { + "methods": [ + "getIndex" + ] + }, + "ExportEntities": { + "methods": [ + "exportEntities" + ] + }, + "ImportEntities": { + "methods": [ + "importEntities" + ] + }, + "CreateIndex": { + "methods": [ + "createIndex" + ] + }, + "DeleteIndex": { + "methods": [ + "deleteIndex" + ] + }, + "ListIndexes": { + "methods": [ + "listIndexes", + "listIndexesStream", + "listIndexesAsync" + ] + } + } + }, + "grpc-fallback": { + "libraryClient": "DatastoreAdminClient", + "rpcs": { + "GetIndex": { + "methods": [ + "getIndex" + ] + }, + "ExportEntities": { + "methods": [ + "exportEntities" + ] + }, + "ImportEntities": { + "methods": [ + "importEntities" + ] + }, + "CreateIndex": { + "methods": [ + "createIndex" + ] + }, + "DeleteIndex": { + "methods": [ + "deleteIndex" + ] + }, + "ListIndexes": { + "methods": [ + "listIndexes", + "listIndexesStream", + "listIndexesAsync" + ] + } + } + } + } + } + } +} diff --git a/handwritten/nodejs-datastore/src/v1/index.ts b/handwritten/nodejs-datastore/src/v1/index.ts new file mode 100644 index 00000000000..8f7c527c2b5 --- /dev/null +++ b/handwritten/nodejs-datastore/src/v1/index.ts @@ -0,0 +1,20 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {DatastoreClient} from './datastore_client'; +export {DatastoreAdminClient} from './datastore_admin_client'; diff --git a/handwritten/nodejs-datastore/system-test/data/index.yaml b/handwritten/nodejs-datastore/system-test/data/index.yaml new file mode 100644 index 00000000000..0900b970f96 --- /dev/null +++ b/handwritten/nodejs-datastore/system-test/data/index.yaml @@ -0,0 +1,29 @@ +indexes: + +- kind: Character + ancestor: yes + properties: + - name: appearances + +- kind: Character + ancestor: yes + properties: + - name: alive + +- kind: Character + ancestor: yes + properties: + - name: family + - name: appearances + +- kind: Character + ancestor: no + properties: + - name: family + - name: appearances + +- kind: Character + ancestor: yes + properties: + - name: name + - name: family diff --git a/handwritten/nodejs-datastore/system-test/datastore.ts b/handwritten/nodejs-datastore/system-test/datastore.ts new file mode 100644 index 00000000000..db9ceb5a05e --- /dev/null +++ b/handwritten/nodejs-datastore/system-test/datastore.ts @@ -0,0 +1,5664 @@ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.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. +import * as assert from 'assert'; +import {readFileSync} from 'fs'; +import * as path from 'path'; +import {after, before, describe, it} from 'mocha'; +import * as yaml from 'js-yaml'; +import {Datastore, DatastoreOptions, Index, Transaction} from '../src'; +import {google} from '../protos/protos'; +import {Storage} from '@google-cloud/storage'; +import {AggregateField, AggregateQuery} from '../src/aggregate'; +import {and, or, PropertyFilter} from '../src/filter'; +import {Entities, entity, Entity} from '../src/entity'; +import {Query, RunQueryInfo, ExecutionStats} from '../src/query'; +import KEY_SYMBOL = entity.KEY_SYMBOL; +import {transactionExpiredError} from '../src/request'; +const testRequests = require('./transaction-spy').testRequests; +import {MockedDatastore} from './transaction-spy'; +const sinon = require('sinon'); +const async = require('async'); +const SECOND_DATABASE_ID = 'multidb-test'; +async.each( + [ + { + namespace: `${Date.now()}`, + }, + { + databaseId: SECOND_DATABASE_ID, + namespace: `second-db-${Date.now()}`, + }, + ], + (clientOptions: DatastoreOptions) => { + describe('Datastore', () => { + let timeBeforeDataCreation: number; + const testKinds: string[] = []; + const datastore = new Datastore(clientOptions); + // Override the Key method so we can track what keys are created during the + // tests. They are then deleted in the `after` hook. + const key = datastore.key; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.key = function (options: any) { + const keyObject = key.call(this, options); + testKinds.push(keyObject.kind); + return keyObject; + }; + const {indexes: DECLARED_INDEXES} = yaml.load( + readFileSync(path.join(__dirname, 'data', 'index.yaml'), 'utf8'), + ) as {indexes: google.datastore.admin.v1.IIndex[]}; + // TODO/DX ensure indexes before testing, and maybe? cleanup indexes after + // possible implications with kokoro project + // Gets the read time of the latest save so that the test isn't flakey due to race condition. + async function getReadTime(path: [{kind: string; name: string}]) { + const projectId = await datastore.getProjectId(); + const request = { + keys: [ + { + path, + partitionId: {namespaceId: datastore.namespace}, + }, + ], + projectId, + }; + const dataClient = datastore.clients_.get('DatastoreClient'); + let results: any; + if (dataClient) { + results = await dataClient['lookup'](request); + } + return parseInt(results[0].readTime.seconds) * 1000; + } + after(async () => { + async function deleteEntities(kind: string) { + const query = datastore.createQuery(kind).select('__key__'); + const [entities] = await datastore.runQuery(query); + const keys = entities.map(entity => { + return entity[datastore.KEY]; + }); + await datastore.delete(keys); + } + await Promise.all(testKinds.map(kind => deleteEntities(kind))); + }); + it('should allocate IDs', async () => { + const keys = await datastore.allocateIds(datastore.key('Kind'), 10); + assert.ok(keys); + }); + it('should get the project id', async () => { + const projectId = await datastore.getProjectId(); + assert.notEqual(projectId, null); + }); + describe('create, retrieve and delete', () => { + const post = { + title: 'How to make the perfect pizza in your grill', + tags: ['pizza', 'grill'], + publishedAt: new Date(), + author: 'Silvano', + isDraft: false, + wordCount: 400, + rating: 5.0, + likes: null, + metadata: { + views: 100, + }, + }; + it('should excludeFromIndexes correctly', async () => { + const longString = Buffer.alloc(1501, '.').toString(); + const postKey = datastore.key(['Post', 'post1']); + const data = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + await datastore.save({ + key: postKey, + data, + excludeFromIndexes: [ + 'longString', + 'longStringArray[]', + 'metadata.obj.longString', + 'metadata.obj.longStringArray[].longString', + 'metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'metadata.longString', + 'metadata.longStringArray[].longString', + 'metadata.longStringArray[].nestedLongStringArray[].longString', + ], + }); + const [entity] = await datastore.get(postKey); + assert.deepStrictEqual(entity[datastore.KEY], postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, data); + await datastore.delete(postKey); + }); + it('should remove index with using wildcard in excludeFromIndexes', async () => { + const longString = Buffer.alloc(1501, '.').toString(); + const postKey = datastore.key(['Post', 'post3']); + const data = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + const excludeFromIndexes = [ + 'longString', + 'longStringArray[]', + 'metadata.longString', + 'metadata.obj.*', + 'metadata.longStringArray[].*', + ]; + await datastore.save({ + key: postKey, + data, + excludeFromIndexes, + }); + const [entity] = await datastore.get(postKey); + assert.deepStrictEqual(entity[datastore.KEY], postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, data); + await datastore.delete(postKey); + }); + it('should auto remove index with excludeLargeProperties enabled', async () => { + const longString = Buffer.alloc(1501, '.').toString(); + const postKey = datastore.key(['Post', 'post2']); + const data = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + await datastore.save({ + key: postKey, + data, + excludeLargeProperties: true, + }); + const [entity] = await datastore.get(postKey); + assert.deepStrictEqual(entity[datastore.KEY], postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, data); + await datastore.delete(postKey); + }); + it('should accurately save/get a large int value via Datastore.int()', async () => { + const postKey = datastore.key('Team'); + const largeIntValueAsString = '9223372036854775807'; + const points = Datastore.int(largeIntValueAsString); + await datastore.save({key: postKey, data: {points}}); + const [entity] = await datastore.get(postKey, {wrapNumbers: true}); + assert.strictEqual(entity.points.value, largeIntValueAsString); + assert.throws(() => entity.points.valueOf()); + await datastore.delete(postKey); + }); + it('should wrap specified properties via IntegerTypeCastOptions.properties', async () => { + const postKey = datastore.key('Scores'); + const largeIntValueAsString = '9223372036854775807'; + const panthers = Datastore.int(largeIntValueAsString); + const broncos = 922337203; + let integerTypeCastFunctionCalled = 0; + await datastore.save({key: postKey, data: {panthers, broncos}}); + const [entity] = await datastore.get(postKey, { + wrapNumbers: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + integerTypeCastFunction: (value: any) => { + integerTypeCastFunctionCalled++; + return value.toString(); + }, + properties: 'panthers', + }, + }); + // verify that value of property 'panthers' was converted via 'integerTypeCastFunction'. + assert.strictEqual(entity.panthers, largeIntValueAsString); + assert.strictEqual(integerTypeCastFunctionCalled, 1); + // verify that value of the property broncos was converted to int by default logic. + assert.strictEqual(entity.broncos, broncos); + await datastore.delete(postKey); + }); + it('should save/get/delete with a key name', async () => { + const postKey = datastore.key(['Post', 'post1']); + await datastore.save({key: postKey, data: post}); + const [entity] = await datastore.get(postKey); + assert.deepStrictEqual(entity[datastore.KEY], postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, post); + await datastore.delete(postKey); + }); + it('should save a nested name/value pair with name as a long string', async () => { + const longString = Buffer.alloc(1501, '.').toString(); + const postKey = datastore.key(['Post', 'post1']); + await datastore.save({ + key: postKey, + data: { + metadata: [ + { + name: longString, + value: 'some-value', + }, + ], + }, + excludeLargeProperties: true, + }); + }); + it('should save a nested name/value pair with value as a long string', async () => { + const longString = Buffer.alloc(1501, '.').toString(); + const postKey = datastore.key(['Post', 'post1']); + await datastore.save({ + key: postKey, + data: [ + { + name: 'some-name', + value: longString, + }, + ], + excludeLargeProperties: true, + }); + }); + describe('multi-db support for read and write operations', () => { + const namespace = `${Date.now()}`; + const keyHierarchy = ['Post', 'post1']; + const defaultDatastore = new Datastore({namespace}); + it('should run a query with another database', async () => { + // First verify that a record gets written to datastore + const postKey = defaultDatastore.key(keyHierarchy); + await defaultDatastore.save({key: postKey, data: post}); + const query = defaultDatastore + .createQuery('Post') + .hasAncestor(postKey); + const [defaultDatastoreResults] = + await defaultDatastore.runQuery(query); + assert.strictEqual(defaultDatastoreResults.length, 1); + const [entity] = await defaultDatastore.get(postKey); + assert.strictEqual(entity.author, 'Silvano'); + // With another database, verify that a query returns no results + const otherDatastore = new Datastore({ + namespace, + databaseId: SECOND_DATABASE_ID, + }); + const [secondDatastoreResults] = + await otherDatastore.runQuery(query); + assert.strictEqual(secondDatastoreResults.length, 0); + const [otherEntity] = await otherDatastore.get(postKey); + assert(typeof otherEntity === 'undefined'); + // Cleanup + await defaultDatastore.delete(postKey); + }); + it('should ensure save works with another database', async () => { + // First verify that the default database is empty + const postKey = defaultDatastore.key(keyHierarchy); + const query = defaultDatastore + .createQuery('Post') + .hasAncestor(postKey); + const [defaultDatastoreResults] = + await defaultDatastore.runQuery(query); + assert.strictEqual(defaultDatastoreResults.length, 0); + const [originalSecondaryResults] = + await defaultDatastore.runQuery(query); + assert.strictEqual(originalSecondaryResults.length, 0); + const [entity] = await defaultDatastore.get(postKey); + assert(typeof entity === 'undefined'); + // With another database, verify that saving to the database works + const otherDatastore = new Datastore({ + namespace, + databaseId: SECOND_DATABASE_ID, + }); + await otherDatastore.save({key: postKey, data: post}); + const [secondDatastoreResults] = + await otherDatastore.runQuery(query); + assert.strictEqual(secondDatastoreResults.length, 1); + const [originalResults] = await defaultDatastore.runQuery(query); + assert.strictEqual(originalResults.length, 0); + const [otherEntity] = await otherDatastore.get(postKey); + assert.strictEqual(otherEntity.author, 'Silvano'); + // Cleanup + await otherDatastore.delete(postKey); + }); + it('should ensure save respects the databaseId parameter per key', async () => { + interface DatastoreData { + key: entity.Key; + data: any; + } + const secondaryDatastore = new Datastore({ + namespace: `${Date.now()}`, + databaseId: SECOND_DATABASE_ID, + }); + // Save all data to the default database + const defaultAuthor = 'default database author'; + const defaultData = Object.assign({}, post); + defaultData.author = defaultAuthor; + const defaultPostKey = defaultDatastore.key([ + 'Post', + 'default post key', + ]); + await defaultDatastore.save({ + key: defaultPostKey, + data: defaultData, + }); + // Save all data to the secondary database + const secondaryIndices = [1, 2, 3]; + const secondaryData: DatastoreData[] = secondaryIndices.map( + number => { + const authorName = 'secondary author ' + number.toString(); + const keyName = 'secondary key ' + number.toString(); + const postData = Object.assign({}, post); + postData.author = authorName; + return { + key: secondaryDatastore.key(['Post', keyName]), + data: postData, + }; + }, + ); + await Promise.all( + secondaryData.map(async datum => secondaryDatastore.save(datum)), + ); + // Next, ensure that the default database has the right records + const query = defaultDatastore + .createQuery('Post') + .hasAncestor(defaultPostKey); + const [defaultDatastoreResults] = + await defaultDatastore.runQuery(query); + assert.strictEqual(defaultDatastoreResults.length, 1); + assert.strictEqual( + defaultDatastoreResults[0].author, + defaultAuthor, + ); + // Next, ensure that the other database has the right records + await Promise.all( + secondaryData.map(async datum => { + const query = secondaryDatastore + .createQuery('Post') + .hasAncestor(datum.key); + const [results] = await secondaryDatastore.runQuery(query); + assert.strictEqual(results.length, 1); + assert.strictEqual(results[0].author, datum.data.author); + }), + ); + // Cleanup + await defaultDatastore.delete(defaultPostKey); + await Promise.all( + secondaryData.map(datum => secondaryDatastore.delete(datum.key)), + ); + }); + }); + it('should save/get/delete from a snapshot', async () => { + function sleep(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + const post2 = { + title: 'Another way to make pizza', + tags: ['pizza', 'grill'], + publishedAt: new Date(), + author: 'Silvano', + isDraft: false, + wordCount: 400, + rating: 5.0, + likes: null, + metadata: { + views: 100, + }, + }; + const path = ['Post', 'post1']; + const postKey = datastore.key(path); + await datastore.save({key: postKey, data: post}); + await sleep(10000); + const savedTime = Date.now(); + await sleep(1000); + // Save new post2 data, but then verify the timestamp read has post1 data + await datastore.save({key: postKey, data: post2}); + const [entity] = await datastore.get(postKey, {readTime: savedTime}); + assert.deepStrictEqual(entity[datastore.KEY], postKey); + const [entityNoOptions] = await datastore.get(postKey); + assert.deepStrictEqual(entityNoOptions[datastore.KEY], postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, post); + delete entityNoOptions[datastore.KEY]; + assert.deepStrictEqual(entityNoOptions, post2); + await datastore.delete(postKey); + }); + it('should save/get/delete with a numeric key id', async () => { + const postKey = datastore.key(['Post', 123456789]); + await datastore.save({key: postKey, data: post}); + const [entity] = await datastore.get(postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, post); + await datastore.delete(postKey); + }); + it('should save/get/delete a buffer', async () => { + const postKey = datastore.key(['Post']); + const data = { + buf: Buffer.from( + '010100000000000000000059400000000000006940', + 'hex', + ), + }; + await datastore.save({key: postKey, data}); + const assignedId = postKey.id; + assert(assignedId); + const [entity] = await datastore.get(postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, data); + await datastore.delete(datastore.key(['Post', assignedId as string])); + }); + it('should save/get/delete an empty buffer', async () => { + const postKey = datastore.key(['Post']); + const data = { + buf: Buffer.from([]), + }; + await datastore.save({key: postKey, data}); + const assignedId = postKey.id; + assert(assignedId); + const [entity] = await datastore.get(postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, data); + await datastore.delete(datastore.key(['Post', assignedId as string])); + }); + it('should save/get/delete with a generated key id', async () => { + const postKey = datastore.key('Post'); + await datastore.save({key: postKey, data: post}); + // The key's path should now be complete. + assert(postKey.id); + const [entity] = await datastore.get(postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, post); + await datastore.delete(postKey); + }); + it('should save/get/update', async () => { + const postKey = datastore.key('Post'); + await datastore.save({key: postKey, data: post}); + const [entity] = await datastore.get(postKey); + assert.strictEqual(entity.title, post.title); + entity.title = 'Updated'; + await datastore.save(entity); + const [entity2] = await datastore.get(postKey); + assert.strictEqual(entity2.title, 'Updated'); + await datastore.delete(postKey); + }); + it('should save/get/merge', async () => { + const postKey = datastore.key(['Post', 1]); + const originalData = { + key: postKey, + data: { + title: 'Original', + status: 'neat', + }, + }; + await datastore.save(originalData); + const updatedData = { + key: postKey, + data: { + title: 'Updated', + }, + }; + await datastore.merge(updatedData); + const [entity] = await datastore.get(postKey); + assert.strictEqual(entity.title, updatedData.data.title); + assert.strictEqual(entity.status, originalData.data.status); + await datastore.delete(postKey); + }); + it('should save and get with a string ID', async () => { + const longIdKey = datastore.key([ + 'Post', + datastore.int('100000000000001234'), + ]); + await datastore.save({ + key: longIdKey, + data: { + test: true, + }, + }); + const [entity] = await datastore.get(longIdKey); + assert.strictEqual(entity.test, true); + }); + it('should fail explicitly set second insert on save', async () => { + const postKey = datastore.key('Post'); + await datastore.save({key: postKey, data: post}); + // The key's path should now be complete. + assert(postKey.id); + await assert.rejects( + datastore.save({ + key: postKey, + method: 'insert', + data: post, + }), + ); + const [entity] = await datastore.get(postKey); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, post); + await datastore.delete(postKey); + }); + it('should fail explicitly set first update on save', async () => { + const postKey = datastore.key('Post'); + await assert.rejects( + datastore.save({ + key: postKey, + method: 'update', + data: post, + }), + ); + }); + it('should save/get/delete multiple entities at once', async () => { + const post2 = { + title: 'How to make the perfect homemade pasta', + tags: ['pasta', 'homemade'], + publishedAt: new Date('2001-01-01T00:00:00.000Z'), + author: 'Silvano', + isDraft: false, + wordCount: 450, + rating: 4.5, + }; + const key1 = datastore.key('Post'); + const key2 = datastore.key('Post'); + await datastore.save([ + {key: key1, data: post}, + {key: key2, data: post2}, + ]); + const [entities] = await datastore.get([key1, key2]); + assert.strictEqual(entities.length, 2); + await datastore.delete([key1, key2]); + }); + it('should get multiple entities in a stream', done => { + const key1 = datastore.key('Post'); + const key2 = datastore.key('Post'); + datastore.save( + [ + {key: key1, data: post}, + {key: key2, data: post}, + ], + err => { + assert.ifError(err); + let numEntitiesEmitted = 0; + datastore + .createReadStream([key1, key2]) + .on('error', done) + .on('data', () => { + numEntitiesEmitted++; + }) + .on('end', () => { + assert.strictEqual(numEntitiesEmitted, 2); + datastore.delete([key1, key2], done); + }); + }, + ); + }); + it('should save keys as a part of entity and query by key', async () => { + const personKey = datastore.key(['People', 'US', 'Person', 'name']); + await datastore.save({ + key: personKey, + data: { + fullName: 'Full name', + linkedTo: personKey, // himself + }, + }); + const query = datastore + .createQuery('Person') + .hasAncestor(datastore.key(['People', 'US'])) + .filter('linkedTo', personKey); + const [results] = await datastore.runQuery(query); + assert.strictEqual(results![0].fullName, 'Full name'); + assert.deepStrictEqual(results![0].linkedTo, personKey); + await datastore.delete(personKey); + }); + it('should save with an empty buffer', async () => { + const key = datastore.key(['TEST']); + const result = await datastore.save({ + key: key, + data: { + name: 'test', + blob: Buffer.from([]), + }, + }); + const mutationResult = result.pop()?.mutationResults?.pop(); + assert.strictEqual(mutationResult?.key?.path?.pop()?.kind, 'TEST'); + }); + describe('entity types', () => { + it('should save and decode an int', async () => { + const integerValue = 2015; + const integerType = Datastore.int(integerValue); + const key = datastore.key('Person'); + await datastore.save({ + key, + data: { + year: integerType, + }, + }); + const [entity] = await datastore.get(key); + assert.strictEqual(entity.year, integerValue); + }); + it('should save and decode a double', async () => { + const doubleValue = 99.99; + const doubleType = Datastore.double(doubleValue); + const key = datastore.key('Person'); + await datastore.save({ + key, + data: { + nines: doubleType, + }, + }); + const [entity] = await datastore.get(key); + assert.strictEqual(entity.nines, doubleValue); + }); + it('should save and decode a geo point', async () => { + const geoPointValue = { + latitude: 40.6894, + longitude: -74.0447, + }; + const geoPointType = Datastore.geoPoint(geoPointValue); + const key = datastore.key('Person'); + await datastore.save({ + key, + data: { + location: geoPointType, + }, + }); + const [entity] = await datastore.get(key); + assert.deepStrictEqual(entity.location, geoPointValue); + }); + }); + }); + describe('querying the datastore', () => { + const ancestor = datastore.key(['Book', 'GoT']); + const keys = [ + // Paths: + ['Rickard'], + ['Rickard', 'Character', 'Eddard'], + ['Catelyn'], + ['Rickard', 'Character', 'Eddard', 'Character', 'Arya'], + ['Rickard', 'Character', 'Eddard', 'Character', 'Sansa'], + ['Rickard', 'Character', 'Eddard', 'Character', 'Robb'], + ['Rickard', 'Character', 'Eddard', 'Character', 'Bran'], + ['Rickard', 'Character', 'Eddard', 'Character', 'Jon Snow'], + ].map(path => { + return datastore.key(['Book', 'GoT', 'Character'].concat(path)); + }); + const characters = [ + { + name: 'Rickard', + family: 'Stark', + appearances: 9, + alive: false, + }, + { + name: 'Eddard', + family: 'Stark', + appearances: 9, + alive: false, + }, + { + name: 'Catelyn', + family: ['Stark', 'Tully'], + appearances: 26, + alive: false, + }, + { + name: 'Arya', + family: 'Stark', + appearances: 33, + alive: true, + }, + { + name: 'Sansa', + family: 'Stark', + appearances: 31, + alive: true, + }, + { + name: 'Robb', + family: 'Stark', + appearances: 22, + alive: false, + }, + { + name: 'Bran', + family: 'Stark', + appearances: 25, + alive: true, + }, + { + name: 'Jon Snow', + family: 'Stark', + appearances: 32, + alive: true, + }, + ]; + before(async () => { + // This 'sleep' function is used to ensure that when data is saved to datastore, + // the time on the server is far enough ahead to be sure to be later than timeBeforeDataCreation + // so that when we read at timeBeforeDataCreation we get a snapshot of data before the save. + function sleep(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + const keysToSave = keys.map((key, index) => { + return { + key, + data: characters[index], + }; + }); + // Save for a key so that a read time can be accessed for snapshot reads. + const emptyData = Object.assign(Object.assign({}, keysToSave[0]), { + data: {}, + }); + await datastore.save(emptyData); + timeBeforeDataCreation = await getReadTime([ + {kind: 'Character', name: 'Rickard'}, + ]); + // Sleep for 3 seconds so that any future reads will be later than timeBeforeDataCreation. + await sleep(3000); + await datastore.save(keysToSave); + }); + after(async () => { + await datastore.delete(keys); + }); + it('should limit queries', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .limit(5); + const [firstEntities, info] = await datastore.runQuery(q); + assert.strictEqual(firstEntities!.length, 5); + const secondQ = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .start(info!.endCursor!); + const [secondEntities] = await datastore.runQuery(secondQ); + assert.strictEqual(secondEntities!.length, 3); + }); + it('should not go over a limit', async () => { + const limit = 3; + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .limit(limit); + const [results] = await datastore.runQuery(q); + assert.strictEqual(results!.length, limit); + }); + it('should run a query as a stream', done => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + let resultsReturned = 0; + datastore + .runQueryStream(q) + .on('error', done) + .on('data', () => resultsReturned++) + .on('end', () => { + assert.strictEqual(resultsReturned, characters.length); + done(); + }); + }); + it('should run a datastore query as a stream via query#runStream', done => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + let resultsReturned = 0; + q.runStream() + .on('error', done) + .on('data', () => resultsReturned++) + .on('end', () => { + assert.strictEqual(resultsReturned, characters.length); + done(); + }); + }); + it('should run a transaction query as a stream via query#runStream', done => { + const transaction = datastore.transaction({readOnly: true}); + const q = transaction.createQuery('Character').hasAncestor(ancestor); + let resultsReturned = 0; + q.runStream() + .on('error', done) + .on('data', () => resultsReturned++) + .on('end', () => { + assert.strictEqual(resultsReturned, characters.length); + done(); + }); + }); + it('should not go over a limit with a stream', done => { + const limit = 3; + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .limit(limit); + let resultsReturned = 0; + datastore + .runQueryStream(q) + .on('error', done) + .on('data', () => resultsReturned++) + .on('end', () => { + assert.strictEqual(resultsReturned, limit); + done(); + }); + }); + it('should filter queries with simple indexes', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .filter('appearances', '>=', 20); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 6); + }); + it('should filter queries with NOT_EQUAL', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .filter('appearances', '!=', 9); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 6); + }); + it('should filter queries with IN', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .filter('appearances', 'IN', [9, 25]); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 3); + }); + it('should filter queries with __key__ and IN', async () => { + const key1 = datastore.key(['Book', 'GoT', 'Character', 'Rickard']); + const key2 = datastore.key([ + 'Book', + 'GoT', + 'Character', + 'Rickard', + 'Character', + 'Eddard', + 'Character', + 'Sansa', + ]); + const key3 = datastore.key([ + 'Book', + 'GoT', + 'Character', + 'Rickard', + 'Character', + 'Eddard', + ]); + const value = [key1, key2, key3]; + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .filter('__key__', 'IN', value); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 3); + assert.deepStrictEqual(entities[0][KEY_SYMBOL], key1); + assert.deepStrictEqual(entities[1][KEY_SYMBOL], key3); + assert.deepStrictEqual(entities[2][KEY_SYMBOL], key2); + }); + it('should filter queries with NOT_IN', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .filter('appearances', 'NOT_IN', [9, 25]); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 5); + }); + it('should filter queries with defined indexes', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .filter('family', 'Stark') + .filter('appearances', '>=', 20); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 6); + }); + describe('with the filter function using the Filter class', () => { + it('should run a query with one property filter', async () => { + const filter = new PropertyFilter('family', '=', 'Stark'); + const q = datastore + .createQuery('Character') + .filter(filter) + .hasAncestor(ancestor); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 8); + }); + it('should run a query with two property filters', async () => { + const q = datastore + .createQuery('Character') + .filter(new PropertyFilter('family', '=', 'Stark')) + .filter(new PropertyFilter('appearances', '>=', 20)); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 6); + }); + it('should run a query using new Filter class with filter', async () => { + const q = datastore + .createQuery('Character') + .filter('family', 'Stark') + .filter(new PropertyFilter('appearances', '>=', 20)); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 6); + for (const entity of entities) { + if (Array.isArray(entity.family)) { + assert.strictEqual(entity.family[0], 'Stark'); + } else { + assert.strictEqual(entity.family, 'Stark'); + } + assert(entity.appearances >= 20); + } + }); + it('should run a query using an AND composite filter', async () => { + const q = datastore + .createQuery('Character') + .filter( + and([ + new PropertyFilter('family', '=', 'Stark'), + new PropertyFilter('appearances', '>=', 20), + ]), + ); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 6); + for (const entity of entities) { + if (Array.isArray(entity.family)) { + assert.strictEqual(entity.family[0], 'Stark'); + } else { + assert.strictEqual(entity.family, 'Stark'); + } + assert(entity.appearances >= 20); + } + }); + it('should run a query using an OR composite filter', async () => { + const q = datastore + .createQuery('Character') + .filter( + or([ + new PropertyFilter('family', '=', 'Stark'), + new PropertyFilter('appearances', '>=', 20), + ]), + ); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 8); + let atLeastOne = false; + for (const entity of entities) { + const familyHasStark = Array.isArray(entity.family) + ? entity.family[0] === 'Stark' + : entity.family === 'Stark'; + const hasEnoughAppearances = entity.appearances >= 20; + if (familyHasStark && !hasEnoughAppearances) { + atLeastOne = true; + } + } + assert(atLeastOne); + }); + describe('using hasAncestor and Filter class', () => { + const secondAncestor = datastore.key([ + 'Book', + 'GoT', + 'Character', + 'Rickard', + 'Character', + 'Eddard', + ]); + it('should run a query using hasAncestor last', async () => { + const q = datastore + .createQuery('Character') + .filter(new PropertyFilter('appearances', '<', 30)) + .hasAncestor(secondAncestor); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 3); + }); + it('should run a query using hasAncestor first', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(secondAncestor) + .filter(new PropertyFilter('appearances', '<', 30)); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 3); + }); + }); + }); + describe('query profiling', () => { + const expectedRunQueryPlan = { + indexesUsed: [ + { + properties: '(__name__ ASC)', + query_scope: 'Collection group', + }, + ], + }; + const expectedRunAggregationQueryPlan = { + indexesUsed: [ + { + properties: '(appearances ASC, __name__ ASC)', + query_scope: 'Includes ancestors', + }, + ], + }; + const compare = (a: {name: string}, b: {name: string}) => { + return a.name > b.name ? 1 : -1; + }; + function checkQueryExecutionStats(executionStats?: ExecutionStats) { + // This function ensures the execution stats returned from the server are correct. + // First fix stats values that will be different every time a query profiling + // request is made so the assertion check only compares values that are + // expected to be the same every time the test is run. + const duration = { + seconds: '0', + nanos: 26806000, + }; + assert(executionStats); + executionStats.executionDuration = duration; + // Then do the assertion check. + assert.deepStrictEqual(executionStats, { + resultsReturned: 8, + executionDuration: duration, + readOperations: 8, + debugStats: { + documents_scanned: '8', + index_entries_scanned: '8', + billing_details: { + min_query_cost: '0', + small_ops: '0', + index_entries_billable: '0', + documents_billable: '8', + }, + }, + }); + } + function checkAggregationQueryExecutionStats( + executionStats?: ExecutionStats, + ) { + // This function ensures the execution stats returned from the server are correct. + // First fix stats values that will be different every time a query profiling + // request is made so the assertion check only compares values that are + // expected to be the same every time the test is run. + const duration = { + seconds: '0', + nanos: 26806000, + }; + assert(executionStats); + executionStats.executionDuration = duration; + // Then do the assertion check. + assert.deepStrictEqual(executionStats, { + resultsReturned: 1, + executionDuration: duration, + readOperations: 1, + debugStats: { + documents_scanned: '0', + index_entries_scanned: '8', + billing_details: { + min_query_cost: '0', + small_ops: '0', + index_entries_billable: '8', + documents_billable: '0', + }, + }, + }); + } + describe('when using transactions', () => { + describe('when using the runQuery function with transactions', () => { + let transaction: Transaction; + let query: Query; + beforeEach(async () => { + transaction = datastore.transaction(); + query = transaction.createQuery('Character'); + }); + it('should run a query in a transaction with no explain options specified', async () => { + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runQuery(query); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert(!info.explainMetrics); + assert.deepStrictEqual( + entities.sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name), + ); + await transaction.commit(); + }); + it('should run a query in a transaction with explain options and analyze not specified', async () => { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Character'); + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runQuery(query, { + explainOptions: {}, + }); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual(entities, []); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + await transaction.commit(); + }); + it('should run a query in a transaction with explain options and analyze set to false', async () => { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Character'); + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runQuery(query, { + explainOptions: {analyze: false}, + }); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual(entities, []); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + await transaction.commit(); + }); + it('should run a query in a transaction with explain options and analyze set to true', async () => { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Character'); + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runQuery(query, { + explainOptions: {analyze: true}, + }); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert.deepStrictEqual( + entities.sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name), + ); + assert(info.explainMetrics); + checkQueryExecutionStats(info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + await transaction.commit(); + }); + }); + describe('when using the runAggregationQuery function with transactions', () => { + const expectedAggregationResults = [ + { + property_1: 187, + }, + ]; + let transaction: Transaction; + let aggregate: AggregateQuery; + beforeEach(async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor); + transaction = datastore.transaction(); + aggregate = transaction + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + }); + it('should run an aggregation query in a transaction with no explain options specified', async () => { + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runAggregationQuery( + aggregate, + {}, + ); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert(!info.explainMetrics); + assert.deepStrictEqual(entities, expectedAggregationResults); + await transaction.commit(); + }); + it('should run an aggregation query in a transaction with empty explain options', async () => { + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runAggregationQuery( + aggregate, + { + explainOptions: {}, + }, + ); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert(info.explainMetrics); + assert.deepStrictEqual(entities, []); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + await transaction.commit(); + }); + it('should run an aggregation query in a transaction with analyze set to false in explain options', async () => { + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runAggregationQuery( + aggregate, + { + explainOptions: { + analyze: false, + }, + }, + ); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert(info.explainMetrics); + assert.deepStrictEqual(entities, []); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + await transaction.commit(); + }); + it('should run an aggregation query in a transaction with analyze set to true in explain options', async () => { + await transaction.run(); + let entities, info; + try { + [entities, info] = await transaction.runAggregationQuery( + aggregate, + { + explainOptions: {analyze: true}, + }, + ); + } catch (e) { + await transaction.rollback(); + assert.fail('transaction failed'); + } + assert(info.explainMetrics); + assert.deepStrictEqual(entities, expectedAggregationResults); + checkAggregationQueryExecutionStats( + info.explainMetrics.executionStats, + ); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + await transaction.commit(); + }); + }); + }); + describe('when using the runQuery function', () => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + it('should run a query with no explain options', async () => { + const [entities, info] = await datastore.runQuery(q); + assert(!info.explainMetrics); + assert.deepStrictEqual( + entities.sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name), + ); + }); + it('should run a query with explain options and no analyze option specified', async () => { + const [entities, info] = await datastore.runQuery(q, { + explainOptions: {}, + }); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + }); + it('should run a query with explain options and analyze set to false', async () => { + const [entities, info] = await datastore.runQuery(q, { + explainOptions: {analyze: false}, + }); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + }); + it('should run a query with explain options and analyze set to true', async () => { + const [entities, info] = await datastore.runQuery(q, { + explainOptions: {analyze: true}, + }); + assert.deepStrictEqual( + entities.sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name), + ); + assert(info.explainMetrics); + checkQueryExecutionStats(info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + }); + }); + describe('when calling run on a Query object', () => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + it('should run an aggregation query with no explain options specified', async () => { + const [entities, info] = await q.run(); + assert(!info.explainMetrics); + assert.deepStrictEqual( + entities.sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name), + ); + }); + it('should run a query with explain options and no value set for analyze', async () => { + const [entities, info] = await q.run({explainOptions: {}}); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + }); + it('should run a query with explain options and analyze set to false', async () => { + const [entities, info] = await q.run({ + explainOptions: {analyze: false}, + }); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + }); + it('should run a query with explain options and analyze set to true', async () => { + const [entities, info] = await q.run({ + explainOptions: {analyze: true}, + }); + assert.deepStrictEqual( + entities.sort(compare).map(entity => entity.name), + [...characters].sort(compare).map(entity => entity.name), + ); + assert(info.explainMetrics); + checkQueryExecutionStats(info.explainMetrics.executionStats); + assert(info.explainMetrics.planSummary); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + }); + }); + describe('when calling runQueryStream', () => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + it('should call runQueryStream with no explain options specified', async () => { + const stream = await datastore.runQueryStream(q); + const entities: Entities = []; + let savedInfo: RunQueryInfo; + stream.on('data', (data: Entity) => { + assert(datastore.KEY in data); + delete data[datastore.KEY]; + entities.push(data); + }); + stream.on('info', (info: any) => { + savedInfo = info; + }); + await new Promise((resolve, reject) => { + stream.on('end', () => { + assert.deepStrictEqual( + entities + .sort(compare) + .map((entity: Entity) => entity?.name), + [...characters].sort(compare).map(entity => entity.name), + ); + assert(!savedInfo.explainMetrics); + resolve(); + }); + }); + }); + it('should call runQueryStream with explain options specified and analyze not specified', async () => { + const stream = await datastore.runQueryStream(q, { + explainOptions: {}, + }); + const entities: Entities = []; + let savedInfo: RunQueryInfo; + stream.on('data', (data: Entity) => { + assert(datastore.KEY in data); + delete data[datastore.KEY]; + entities.push(data); + }); + stream.on('info', (info: any) => { + savedInfo = info; + }); + await new Promise((resolve, reject) => { + stream.on('end', () => { + assert.deepStrictEqual(entities, []); + assert(savedInfo.explainMetrics); + assert(!savedInfo.explainMetrics.executionStats); + assert.deepStrictEqual( + savedInfo.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + resolve(); + }); + }); + }); + it('should call runQueryStream with explain options specified and analyze set to false', async () => { + const stream = await datastore.runQueryStream(q, { + explainOptions: { + analyze: false, + }, + }); + const entities: Entities = []; + let savedInfo: RunQueryInfo; + stream.on('data', (data: Entity) => { + assert(datastore.KEY in data); + delete data[datastore.KEY]; + entities.push(data); + }); + stream.on('info', (info: any) => { + savedInfo = info; + }); + await new Promise((resolve, reject) => { + stream.on('end', () => { + assert.deepStrictEqual(entities, []); + assert(savedInfo.explainMetrics); + assert(!savedInfo.explainMetrics.executionStats); + assert.deepStrictEqual( + savedInfo.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + resolve(); + }); + }); + }); + it('should call runQueryStream with explain options specified and analyze set to true', async () => { + const stream = await datastore.runQueryStream(q, { + explainOptions: {analyze: true}, + }); + const entities: Entities = []; + let savedInfo: RunQueryInfo; + stream.on('data', (data: Entity) => { + assert(datastore.KEY in data); + delete data[datastore.KEY]; + entities.push(data); + }); + stream.on('info', (info: any) => { + savedInfo = info; + }); + await new Promise((resolve, reject) => { + stream.on('end', () => { + assert.deepStrictEqual( + entities + .sort(compare) + .map((entity: Entity) => entity?.name), + [...characters].sort(compare).map(entity => entity.name), + ); + assert(savedInfo.explainMetrics); + checkQueryExecutionStats( + savedInfo.explainMetrics.executionStats, + ); + assert.deepStrictEqual( + savedInfo.explainMetrics.planSummary, + expectedRunQueryPlan, + ); + resolve(); + }); + }); + }); + }); + describe('when using the runAggregationQuery function', () => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + const expectedAggregationResults = [ + { + property_1: 187, + }, + ]; + it('should run an aggregation query with no mode specified', async () => { + const [entities, info] = + await datastore.runAggregationQuery(aggregate); + assert(!info.explainMetrics); + assert.deepStrictEqual(entities, expectedAggregationResults); + }); + it('should run an aggregation query with explain options specified and analyze not specified', async () => { + const [entities, info] = await datastore.runAggregationQuery( + aggregate, + { + explainOptions: {}, + }, + ); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + }); + it('should run an aggregation query with explain options specified and analyze set to false', async () => { + const [entities, info] = await datastore.runAggregationQuery( + aggregate, + { + explainOptions: {analyze: false}, + }, + ); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.explainMetrics.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + }); + it('should run an aggregation query with explain options and analyze set to true', async () => { + const [entities, info] = await datastore.runAggregationQuery( + aggregate, + { + explainOptions: {analyze: true}, + }, + ); + assert.deepStrictEqual(entities, expectedAggregationResults); + assert(info.explainMetrics); + checkAggregationQueryExecutionStats( + info.explainMetrics.executionStats, + ); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + }); + }); + describe('when using run on an AggregationQuery object', () => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + const expectedAggregationResults = [ + { + property_1: 187, + }, + ]; + it('should run an aggregation query with no explain options', async () => { + const [entities, info] = await aggregate.run(); + assert(!info.explainMetrics); + assert.deepStrictEqual(entities, expectedAggregationResults); + }); + it('should run an aggregation query with explain options and analyze not specified', async () => { + const [entities, info] = await aggregate.run({ + explainOptions: {}, + }); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + }); + it('should run an aggregation query with explain options and analyze set to false', async () => { + const [entities, info] = await aggregate.run({ + explainOptions: { + analyze: false, + }, + }); + assert.deepStrictEqual(entities, []); + assert(info.explainMetrics); + assert(!info.executionStats); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + }); + it('should run an aggregation query with explain options specified and analyze set to true', async () => { + const [entities, info] = await aggregate.run({ + explainOptions: {analyze: true}, + }); + assert.deepStrictEqual(entities, expectedAggregationResults); + assert(info.explainMetrics); + checkAggregationQueryExecutionStats( + info.explainMetrics.executionStats, + ); + assert.deepStrictEqual( + info.explainMetrics.planSummary, + expectedRunAggregationQueryPlan, + ); + }); + }); + }); + describe('with a sum filter', () => { + it('should run a sum aggregation', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 187}]); + }); + it('should run a sum aggregation with a list of aggregates', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.sum('appearances'), + AggregateField.sum('appearances'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [ + {property_1: 187, property_2: 187}, + ]); + }); + it('should run a sum aggregation having other filters', async () => { + const q = datastore + .createQuery('Character') + .filter('family', 'Stark') + .filter('appearances', '>=', 20); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances').alias('sum1')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{sum1: 169}]); + }); + it('should run a sum aggregate filter with an alias', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances').alias('sum1')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{sum1: 187}]); + }); + it('should do multiple sum aggregations with aliases', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.sum('appearances').alias('sum1'), + AggregateField.sum('appearances').alias('sum2'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{sum1: 187, sum2: 187}]); + }); + it('should run a sum aggregation filter with a limit', async () => { + // When using a limit the test appears to use data points with the lowest appearance values. + const q = datastore.createQuery('Character').limit(5); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 91}]); + }); + it('should run a sum aggregate filter with a limit and an alias', async () => { + const q = datastore.createQuery('Character').limit(7); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.sum('appearances').alias('sum1'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{sum1: 154}]); + }); + it('should run a sum aggregate filter against a non-numeric property value', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([AggregateField.sum('family').alias('sum1')]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{sum1: 0}]); + }); + it('should run a sum aggregate filter against __key__ property value', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([AggregateField.sum('__key__').alias('sum1')]); + try { + await datastore.runAggregationQuery(aggregate); + assert.fail('The request should have failed.'); + } catch (err: any) { + assert.strictEqual( + err.message, + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', + ); + } + }); + it('should run a sum aggregate filter against a query that returns no results', async () => { + const q = datastore + .createQuery('Character') + .filter('family', 'NoMatch'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.sum('appearances').alias('sum1'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{sum1: 0}]); + }); + it('should run a sum aggregate filter against a query from before the data creation', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.sum('appearances').alias('sum1'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate, { + readTime: timeBeforeDataCreation, + }); + assert.deepStrictEqual(results, [{sum1: 0}]); + }); + it('should run a sum aggregate filter using the alias function, but with no alias', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([AggregateField.sum('appearances').alias()]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 187}]); + }); + }); + describe('with an average filter', () => { + it('should run an average aggregation', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.average('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 23.375}]); + }); + it('should run an average aggregation with a list of aggregates', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.average('appearances'), + AggregateField.average('appearances'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [ + {property_1: 23.375, property_2: 23.375}, + ]); + }); + it('should run an average aggregation having other filters', async () => { + const q = datastore + .createQuery('Character') + .filter('family', 'Stark') + .filter('appearances', '>=', 20); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation( + AggregateField.average('appearances').alias('avg1'), + ); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{avg1: 28.166666666666668}]); + }); + it('should run an average aggregate filter with an alias', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation( + AggregateField.average('appearances').alias('avg1'), + ); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{avg1: 23.375}]); + }); + it('should do multiple average aggregations with aliases', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.average('appearances').alias('avg1'), + AggregateField.average('appearances').alias('avg2'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{avg1: 23.375, avg2: 23.375}]); + }); + it('should run an average aggregation filter with a limit', async () => { + const q = datastore.createQuery('Character').limit(5); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.average('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 18.2}]); + }); + it('should run an average aggregate filter with a limit and an alias', async () => { + const q = datastore.createQuery('Character').limit(7); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.average('appearances').alias('avg1'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{avg1: 22}]); + }); + it('should run an average aggregate filter against a non-numeric property value', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.average('family').alias('avg1'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{avg1: null}]); + }); + it('should run an average aggregate filter against __key__ property value', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.average('__key__').alias('avg1'), + ]); + try { + await datastore.runAggregationQuery(aggregate); + assert.fail('The request should have failed.'); + } catch (err: any) { + assert.strictEqual( + err.message, + '3 INVALID_ARGUMENT: Aggregations are not supported for the property: __key__', + ); + } + }); + it('should run an average aggregate filter against a query that returns no results', async () => { + const q = datastore + .createQuery('Character') + .filter('family', 'NoMatch'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.average('appearances').alias('avg1'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{avg1: null}]); + }); + it('should run an average aggregate filter against a query from before the data creation', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.average('appearances').alias('avg1'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate, { + readTime: timeBeforeDataCreation, + }); + assert.deepStrictEqual(results, [{avg1: null}]); + }); + it('should run an average aggregate filter using the alias function, but with no alias', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([AggregateField.average('appearances').alias()]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 23.375}]); + }); + }); + describe('with a count filter', () => { + it('should run a count aggregation', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.count()); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 8}]); + }); + it('should run a count aggregation with a list of aggregates', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.count(), + AggregateField.count(), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 8, property_2: 8}]); + }); + it('should run a count aggregation having other filters', async () => { + const q = datastore + .createQuery('Character') + .filter('family', 'Stark') + .filter('appearances', '>=', 20); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.count().alias('total')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{total: 6}]); + }); + it('should run a count aggregate filter with an alias', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.count().alias('total')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{total: 8}]); + }); + it('should do multiple count aggregations with aliases', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.count().alias('total'), + AggregateField.count().alias('total2'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{total: 8, total2: 8}]); + }); + it('should run a count aggregation filter with a limit', async () => { + const q = datastore.createQuery('Character').limit(5); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.count()); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 5}]); + }); + it('should run a count aggregate filter with a limit and an alias', async () => { + const q = datastore.createQuery('Character').limit(7); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([AggregateField.count().alias('total')]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{total: 7}]); + }); + it('should run a count aggregate filter using the alias function, but with no alias', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([AggregateField.count().alias()]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 8}]); + }); + }); + describe('with multiple types of filters', () => { + it('should run multiple types of aggregations with a list of aggregates', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.count(), + AggregateField.sum('appearances'), + AggregateField.average('appearances'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [ + {property_1: 8, property_2: 187, property_3: 23.375}, + ]); + }); + it('should run multiple types of aggregations with and without aliases', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.count(), + AggregateField.average('appearances'), + AggregateField.count().alias('alias_count'), + AggregateField.sum('appearances').alias('alias_sum'), + AggregateField.average('appearances').alias('alias_average'), + ]); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [ + { + property_1: 8, + property_2: 23.375, + alias_count: 8, + alias_sum: 187, + alias_average: 23.375, + }, + ]); + }); + it('should throw an error when too many aggregations are run', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregations([ + AggregateField.count(), + AggregateField.sum('appearances'), + AggregateField.average('appearances'), + AggregateField.count().alias('alias_count'), + AggregateField.sum('appearances').alias('alias_sum'), + AggregateField.average('appearances').alias('alias_average'), + ]); + try { + await datastore.runAggregationQuery(aggregate); + } catch (err: any) { + assert.strictEqual( + err.message, + '3 INVALID_ARGUMENT: The maximum number of aggregations allowed in an aggregation query is 5. Received: 6', + ); + } + }); + }); + it('should filter by ancestor', async () => { + const q = datastore.createQuery('Character').hasAncestor(ancestor); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities.length, characters.length); + }); + it('should construct filters by null status', async () => { + assert.strictEqual( + datastore + .createQuery('Character') + .filter('status', null) + .filters.pop()?.val, + null, + ); + assert.strictEqual( + datastore + .createQuery('Character') + .filter('status', '=', null) + .filters.pop()?.val, + null, + ); + }); + it('should filter by key', async () => { + const key = datastore.key(['Book', 'GoT', 'Character', 'Rickard']); + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .filter('__key__', key); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 1); + }); + it('should order queries', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .order('appearances'); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities![0].name, characters[0].name); + assert.strictEqual(entities![7].name, characters[3].name); + }); + it('should select projections', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .select(['name', 'family']); + const [entities] = await datastore.runQuery(q); + delete entities[0][datastore.KEY]; + assert.deepStrictEqual(entities![0], { + name: 'Arya', + family: 'Stark', + }); + delete entities[8][datastore.KEY]; + assert.deepStrictEqual(entities![8], { + name: 'Sansa', + family: 'Stark', + }); + }); + it('should paginate with offset and limit', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .offset(2) + .limit(3) + .order('appearances'); + const [entities, info] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, 3); + assert.strictEqual(entities![0].name, 'Robb'); + assert.strictEqual(entities![2].name, 'Catelyn'); + const secondQ = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .order('appearances') + .start(info!.endCursor!); + const [secondEntities] = await datastore.runQuery(secondQ); + assert.strictEqual(secondEntities!.length, 3); + assert.strictEqual(secondEntities![0].name, 'Sansa'); + assert.strictEqual(secondEntities![2].name, 'Arya'); + }); + it('should resume from a start cursor', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .offset(2) + .limit(2) + .order('appearances'); + const [, info] = await datastore.runQuery(q); + const secondQ = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .order('appearances') + .start(info!.endCursor!); + const [secondEntities] = await datastore.runQuery(secondQ); + assert.strictEqual(secondEntities!.length, 4); + assert.strictEqual(secondEntities![0].name, 'Catelyn'); + assert.strictEqual(secondEntities![3].name, 'Arya'); + }); + it('should group queries', async () => { + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor) + .groupBy('appearances'); + const [entities] = await datastore.runQuery(q); + assert.strictEqual(entities!.length, characters.length - 1); + }); + it('should query from the Query object', async () => { + await datastore.createQuery('Character').run(); + }); + }); + describe('querying the datastore with an overflow data set', () => { + const keys = [ + // Paths: + ['Rickard'], + ['Rickard', 'Character', 'Eddard'], + ].map(path => { + return datastore.key(['Book', 'GoT', 'Character'].concat(path)); + }); + const characters = [ + { + name: 'Rickard', + family: 'Stark', + // eslint-disable-next-line @typescript-eslint/no-loss-of-precision + appearances: 9223372036854775807, + alive: false, + }, + { + name: 'Eddard', + family: 'Stark', + // eslint-disable-next-line @typescript-eslint/no-loss-of-precision + appearances: 9223372036854775807, + alive: false, + }, + ]; + before(async () => { + const keysToSave = keys.map((key, index) => { + return { + key, + data: characters[index], + }; + }); + await datastore.save(keysToSave); + }); + after(async () => { + await datastore.delete(keys); + }); + it('should run a sum aggregation with an overflow dataset', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [ + {property_1: -18446744073709552000}, + ]); + }); + it('should run an average aggregation with an overflow dataset', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.average('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: -9223372036854776000}]); + }); + }); + describe('querying the datastore with an NaN in the data set', () => { + const keys = [ + // Paths: + ['Rickard'], + ['Rickard', 'Character', 'Eddard'], + ].map(path => { + return datastore.key(['Book', 'GoT', 'Character'].concat(path)); + }); + const characters = [ + { + name: 'Rickard', + family: 'Stark', + appearances: 4, + alive: false, + }, + { + name: 'Eddard', + family: 'Stark', + appearances: null, + alive: false, + }, + ]; + before(async () => { + const keysToSave = keys.map((key, index) => { + return { + key, + data: characters[index], + }; + }); + await datastore.save(keysToSave); + }); + after(async () => { + await datastore.delete(keys); + }); + it('should run a sum aggregation', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 4}]); + }); + it('should run an average aggregation', async () => { + const q = datastore.createQuery('Character'); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.average('appearances')); + const [results] = await datastore.runAggregationQuery(aggregate); + assert.deepStrictEqual(results, [{property_1: 4}]); + }); + }); + describe('transactions with and without run', () => { + describe('test to make sure various endpoints report an expired state', () => { + async.each( + [ + { + name: 'with commit', + setupExpiredFn: async (tx: Transaction) => { + await tx.commit(); + }, + }, + { + name: 'with rollback', + setupExpiredFn: async (tx: Transaction) => { + // We expect rollback to fail with an aborted error when + // tx.run hasn't been called yet so these tests are only + // valid when tx.run() has already been called. + await tx.run(); + await tx.rollback(); + }, + }, + ], + (test: { + name: string; + setupExpiredFn: (tx: Transaction) => Promise; + }) => { + describe(test.name, () => { + describe('get', () => { + it('with transaction.run', async () => { + try { + const key = datastore.key(['Company', 'Google']); + const transaction: Transaction = datastore.transaction(); + await transaction.run(); + await test.setupExpiredFn(transaction); + await transaction.get(key); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + it('without transaction.run', async () => { + try { + const key = datastore.key(['Company', 'Google']); + const transaction = datastore.transaction(); + await test.setupExpiredFn(transaction); + await transaction.get(key); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + }); + describe('runQuery', () => { + it('with transaction.run', async () => { + try { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Company'); + await transaction.run(); + await test.setupExpiredFn(transaction); + await transaction.runQuery(query); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + it('without transaction.run', async () => { + try { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Company'); + await test.setupExpiredFn(transaction); + await transaction.runQuery(query); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + }); + describe('runAggregationQuery', () => { + it('with transaction.run', async () => { + try { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Company'); + const aggregationQuery = transaction + .createAggregationQuery(query) + .count('total'); + await transaction.run(); + await test.setupExpiredFn(transaction); + await transaction.runAggregationQuery(aggregationQuery); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + it('without transaction.run', async () => { + try { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Company'); + const aggregationQuery = transaction + .createAggregationQuery(query) + .count('total'); + await test.setupExpiredFn(transaction); + await transaction.runAggregationQuery(aggregationQuery); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + }); + describe('runQueryStream', () => { + it('with transaction.run', async () => { + try { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Company'); + await transaction.run(); + await test.setupExpiredFn(transaction); + transaction.runQueryStream(query); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + it('without transaction.run', async () => { + try { + const transaction = datastore.transaction(); + const query = transaction.createQuery('Company'); + await test.setupExpiredFn(transaction); + transaction.runQueryStream(query); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + }); + describe('createReadStream', () => { + it('with transaction.run', async () => { + try { + const datastore = new Datastore(clientOptions); + const key = datastore.key(['Company', 'Google']); + const transaction = datastore.transaction(); + await transaction.run(); + await test.setupExpiredFn(transaction); + transaction.createReadStream(key); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + it('without transaction.run', async () => { + try { + const datastore = new Datastore(clientOptions); + const key = datastore.key(['Company', 'Google']); + const transaction = datastore.transaction(); + await test.setupExpiredFn(transaction); + transaction.createReadStream(key); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + }); + describe('commit', () => { + it('with transaction.run', async () => { + try { + const transaction = datastore.transaction(); + await transaction.run(); + await test.setupExpiredFn(transaction); + await transaction.commit(); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + it('without transaction.run', async () => { + try { + const transaction = datastore.transaction(); + await test.setupExpiredFn(transaction); + await transaction.commit(); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + }); + describe('rollback', () => { + it('with transaction.run', async () => { + try { + const transaction = datastore.transaction(); + await transaction.run(); + await test.setupExpiredFn(transaction); + await transaction.rollback(); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + it('without transaction.run', async () => { + try { + const transaction = datastore.transaction(); + await test.setupExpiredFn(transaction); + await transaction.rollback(); + assert.fail('The expire error should have appeared'); + } catch (err: any) { + assert.strictEqual(err.message, transactionExpiredError); + } + }); + }); + }); + }, + ); + }); + describe('comparing times with and without transaction.run', async () => { + const key = datastore.key(['Company', 'Google']); + // Record time for transaction with run + const startTimeWithRun = new Date().getTime(); + const transactionWithRun = datastore.transaction({readOnly: true}); + await transactionWithRun.run(); + await Promise.all([ + transactionWithRun.get(key), + transactionWithRun.get(key), + ]); + await transactionWithRun.commit(); + const timeElapsedWithRun = new Date().getTime() - startTimeWithRun; + // Record time for transaction without run + const startTimeWithoutRun = new Date().getTime(); + const transactionWithoutRun = datastore.transaction({readOnly: true}); + await Promise.all([ + transactionWithoutRun.get(key), + transactionWithoutRun.get(key), + ]); + await transactionWithoutRun.commit(); + const timeElapsedWithoutRun = + new Date().getTime() - startTimeWithoutRun; + assert(timeElapsedWithoutRun < timeElapsedWithRun); + }); + describe('lookup, put, commit', () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + afterEach(async () => { + await datastore.delete(key); + }); + async function doLookupPutCommit(transaction: Transaction) { + const [firstRead] = await transaction.get(key); + assert(!firstRead); + transaction.save({key, data: obj}); + await transaction.commit(); + const [entity] = await datastore.get(key); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, obj); + } + it('should run in a transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + await doLookupPutCommit(transaction); + }); + it('should run in a transaction without run', async () => { + const transaction = datastore.transaction(); + await doLookupPutCommit(transaction); + }); + }); + describe('put, lookup, commit', () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + afterEach(async () => { + await datastore.delete(key); + }); + async function doPutLookupCommit(transaction: Transaction) { + transaction.save({key, data: obj}); + const [firstRead] = await transaction.get(key); + assert(!firstRead); + await transaction.commit(); + const [entity] = await datastore.get(key); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, obj); + } + it('should run in a transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + await doPutLookupCommit(transaction); + }); + it('should run in a transaction without run', async () => { + const transaction = datastore.transaction(); + await doPutLookupCommit(transaction); + }); + }); + describe('runQuery, put, commit', () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + afterEach(async () => { + await datastore.delete(key); + }); + async function doRunQueryPutCommit(transaction: Transaction) { + const query = transaction.createQuery('Company'); + const [results] = await transaction.runQuery(query); + assert.deepStrictEqual(results, []); + transaction.save({key, data: obj}); + await transaction.commit(); + const [entity] = await datastore.get(key); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, obj); + } + it('should run in a transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + await doRunQueryPutCommit(transaction); + }); + it('should run in a transaction without run', async () => { + const transaction = datastore.transaction(); + await doRunQueryPutCommit(transaction); + }); + }); + describe('readOnly for runQuery looks at snapshot from first read', () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + afterEach(async () => { + await datastore.delete(key); + }); + async function doPutRunQueryCommit(transaction: Transaction) { + const query = transaction.createQuery('Company'); + const [results] = await transaction.runQuery(query); + assert.deepStrictEqual(results, []); + await datastore.save({key, data: obj}); + const [results2] = await transaction.runQuery(query); + assert.deepStrictEqual(results2, []); + await transaction.commit(); + } + it('should run in a transaction', async () => { + const transaction = datastore.transaction({readOnly: true}); + await transaction.run(); + await doPutRunQueryCommit(transaction); + }); + it('should run in a transaction without run', async () => { + const transaction = datastore.transaction({readOnly: true}); + await doPutRunQueryCommit(transaction); + }); + }); + describe('put, runQuery, commit', () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + afterEach(async () => { + await datastore.delete(key); + }); + async function doPutRunQueryCommit(transaction: Transaction) { + transaction.save({key, data: obj}); + const query = transaction.createQuery('Company'); + const [results] = await transaction.runQuery(query); + assert.deepStrictEqual(results, []); + await transaction.commit(); + const [entity] = await datastore.get(key); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, obj); + } + it('should run in a transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + await doPutRunQueryCommit(transaction); + }); + it('should run in a transaction without run', async () => { + const transaction = datastore.transaction(); + await doPutRunQueryCommit(transaction); + }); + }); + describe('runAggregationQuery, put, commit', () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + afterEach(async () => { + await datastore.delete(key); + }); + async function doRunAggregationQueryPutCommit( + transaction: Transaction, + ) { + const query = transaction.createQuery('Company'); + const aggregateQuery = transaction + .createAggregationQuery(query) + .count('total'); + const [results] = + await transaction.runAggregationQuery(aggregateQuery); + assert.deepStrictEqual(results, [{total: 0}]); + transaction.save({key, data: obj}); + await transaction.commit(); + const [entity] = await datastore.get(key); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, obj); + } + it('should run in a transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + await doRunAggregationQueryPutCommit(transaction); + }); + it('should run in a transaction without run', async () => { + const transaction = datastore.transaction(); + await doRunAggregationQueryPutCommit(transaction); + }); + }); + describe('put, runAggregationQuery, commit', () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + afterEach(async () => { + await datastore.delete(key); + }); + async function doPutRunAggregationQueryCommit( + transaction: Transaction, + ) { + transaction.save({key, data: obj}); + const query = transaction.createQuery('Company'); + const aggregateQuery = transaction + .createAggregationQuery(query) + .count('total'); + const [results] = + await transaction.runAggregationQuery(aggregateQuery); + assert.deepStrictEqual(results, [{total: 0}]); + await transaction.commit(); + const [entity] = await datastore.get(key); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, obj); + } + it('should run in a transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + await doPutRunAggregationQueryCommit(transaction); + }); + it('should run in a transaction without run', async () => { + const transaction = datastore.transaction(); + await doPutRunAggregationQueryCommit(transaction); + }); + }); + }); + describe('transactions', () => { + before(async () => { + // This 'sleep' function is used to ensure that when data is saved to datastore, + // the time on the server is far enough ahead to be sure to be later than timeBeforeDataCreation + // so that when we read at timeBeforeDataCreation we get a snapshot of data before the save. + const key = datastore.key(['Company', 'Google']); + function sleep(ms: number) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + // Save for a key so that a read time can be accessed for snapshot reads. + const emptyData = { + key, + data: {}, + }; + await datastore.save(emptyData); + // Sleep for 10 seconds to ensure timeBeforeDataCreation includes the empty data + await sleep(10000); + timeBeforeDataCreation = await getReadTime([ + {kind: 'Company', name: 'Google'}, + ]); + // Sleep for 10 seconds so that any future reads will be later than timeBeforeDataCreation. + await sleep(10000); + }); + it('should run in a transaction', async () => { + const key = datastore.key(['Company', 'Google']); + const obj = { + url: 'www.google.com', + }; + const transaction = datastore.transaction(); + await transaction.run(); + await transaction.get(key); + transaction.save({key, data: obj}); + await transaction.commit(); + const [entity] = await datastore.get(key); + delete entity[datastore.KEY]; + assert.deepStrictEqual(entity, obj); + }); + it('should commit all saves and deletes at the end', async () => { + const deleteKey = datastore.key(['Company', 'Subway']); + const key = datastore.key(['Company', 'Google']); + const incompleteKey = datastore.key('Company'); + await datastore.save({ + key: deleteKey, + data: {}, + }); + const transaction = datastore.transaction(); + await transaction.run(); + transaction.delete(deleteKey); + transaction.save([ + { + key, + data: {rating: 10}, + }, + { + key: incompleteKey, + data: {rating: 100}, + }, + ]); + await transaction.commit(); + // Incomplete key should have been given an ID. + assert.strictEqual(incompleteKey.path.length, 2); + const [[deletedEntity], [fetchedEntity]] = await Promise.all([ + // Deletes the key that is in the deletion queue. + datastore.get(deleteKey), + // Updates data on the key. + datastore.get(key), + ]); + assert.strictEqual(typeof deletedEntity, 'undefined'); + assert.strictEqual(fetchedEntity.rating, 10); + }); + it('should use the last modification to a key', async () => { + const incompleteKey = datastore.key('Company'); + const key = datastore.key(['Company', 'Google']); + const transaction = datastore.transaction(); + await transaction.run(); + transaction.save([ + { + key, + data: { + rating: 10, + }, + }, + { + key: incompleteKey, + data: { + rating: 100, + }, + }, + ]); + transaction.delete(key); + await transaction.commit(); + // Should not return a result. + const [entity] = await datastore.get(key); + assert.strictEqual(entity, undefined); + // Incomplete key should have been given an id. + assert.strictEqual(incompleteKey.path.length, 2); + }); + it('should query within a transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + const query = transaction.createQuery('Company'); + let entities; + try { + [entities] = await query.run(); + } catch (e) { + await transaction.rollback(); + return; + } + assert(entities!.length > 0); + await transaction.commit(); + }); + it('should query within a transaction at a previous read time', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + const query = transaction.createQuery('Company'); + let entitiesBefore; + let entitiesNow; + try { + [entitiesBefore] = await query.run({ + readTime: timeBeforeDataCreation, + }); + [entitiesNow] = await query.run({}); + } catch (e) { + await transaction.rollback(); + return; + } + assert(entitiesBefore!.length < entitiesNow!.length); + await transaction.commit(); + }); + describe('aggregate query within a transaction', async () => { + it('should run a query and return the results', async () => { + // Add a test here to verify what the data is at this time. + // This will be a valuable reference for tests in this describe block. + const query = datastore.createQuery('Company'); + const [results] = await datastore.runQuery(query); + assert.deepStrictEqual( + results.map(result => result.rating), + [100, 100], + ); + }); + it('should aggregate query within a count transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + const query = transaction.createQuery('Company'); + const aggregateQuery = transaction + .createAggregationQuery(query) + .count('total'); + let result; + try { + [result] = await aggregateQuery.run(); + } catch (e) { + await transaction.rollback(); + throw e; + } + assert.deepStrictEqual(result, [{total: 2}]); + await transaction.commit(); + }); + it('should aggregate query within a sum transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + const query = transaction.createQuery('Company'); + const aggregateQuery = transaction + .createAggregationQuery(query) + .sum('rating', 'total rating'); + let result; + try { + [result] = await aggregateQuery.run(); + } catch (e) { + await transaction.rollback(); + throw e; + } + assert.deepStrictEqual(result, [{'total rating': 200}]); + await transaction.commit(); + }); + it('should aggregate query within a average transaction', async () => { + const transaction = datastore.transaction(); + await transaction.run(); + const query = transaction.createQuery('Company'); + const aggregateQuery = transaction + .createAggregationQuery(query) + .average('rating', 'average rating'); + let result; + try { + [result] = await aggregateQuery.run(); + } catch (e) { + await transaction.rollback(); + throw e; + } + assert.deepStrictEqual(result, [{'average rating': 100}]); + await transaction.commit(); + }); + it('readOnly transaction should see consistent snapshot of database', async () => { + async function getResults(transaction: Transaction) { + const query = transaction.createQuery('Company'); + const aggregateQuery = transaction + .createAggregationQuery(query) + .count('total'); + let result; + try { + [result] = await aggregateQuery.run(); + } catch (e) { + await transaction.rollback(); + throw e; + } + return result; + } + const key = datastore.key(['Company', 'Google']); + const transaction = datastore.transaction({readOnly: true}); + await transaction.run(); + const results = await getResults(transaction); + assert.deepStrictEqual(results, [{total: 2}]); + await datastore.save([ + { + key, + data: { + rating: 100, + }, + }, + ]); + const resultsAgain = await getResults(transaction); + assert.deepStrictEqual(resultsAgain, [{total: 2}]); + await transaction.commit(); + }); + it('readOnly transaction should see consistent snapshot of database without transaction.run', async () => { + async function getResults(transaction: Transaction) { + const query = transaction.createQuery('Company'); + const aggregateQuery = transaction + .createAggregationQuery(query) + .count('total'); + let result; + try { + [result] = await aggregateQuery.run(); + } catch (e) { + await transaction.rollback(); + throw e; + } + return result; + } + const key = datastore.key(['Company', 'Google']); + const transaction = datastore.transaction({readOnly: true}); + const results = await getResults(transaction); + assert.deepStrictEqual(results, [{total: 3}]); + await datastore.save([ + { + key, + data: { + rating: 100, + }, + }, + ]); + const resultsAgain = await getResults(transaction); + assert.deepStrictEqual(resultsAgain, [{total: 3}]); + await transaction.commit(); + }); + }); + it('should read in a readOnly transaction', async () => { + const transaction = datastore.transaction({readOnly: true}); + const key = datastore.key(['Company', 'Google']); + await transaction.run(); + await transaction.get(key); + }); + it('should read in a readOnly transaction without transaction.run', async () => { + const transaction = datastore.transaction({readOnly: true}); + const key = datastore.key(['Company', 'Google']); + await transaction.get(key); + }); + it('should not write in a readOnly transaction', async () => { + const transaction = datastore.transaction({readOnly: true}); + const key = datastore.key(['Company', 'Google']); + await transaction.run(); + await transaction.get(key); + transaction.save({key, data: {}}); + await assert.rejects(transaction.commit()); + }); + }); + describe('indexes', () => { + // @TODO: Until the protos support creating indexes, these tests depend on + // the remote state of declared indexes. Could be flaky! + it('should get all indexes', async () => { + const [indexes] = await datastore.getIndexes(); + assert.ok( + indexes.length >= DECLARED_INDEXES.length, + 'has at least the number of indexes per system-test/data/index.yaml', + ); + // Comparing index.yaml and the actual defined index in Datastore requires + // assumptions to complete a shape transformation, so let's just see if + // a returned index has the right shape and not inspect the values. + const [firstIndex] = indexes; + assert.ok(firstIndex, 'first index is readable'); + assert.ok( + firstIndex.metadata!.properties, + 'has properties collection', + ); + assert.ok( + firstIndex.metadata!.properties.length, + 'with properties inside', + ); + assert.ok(firstIndex.metadata!.ancestor, 'has the ancestor property'); + }); + it('should get all indexes as a stream', done => { + const indexes: Index[] = []; + datastore + .getIndexesStream() + .on('error', done) + .on('data', index => { + indexes.push(index); + }) + .on('end', () => { + assert(indexes.length >= DECLARED_INDEXES.length); + done(); + }); + }); + it('should get a specific index', async () => { + const [indexes] = await datastore.getIndexes(); + const [firstIndex] = indexes; + const index = datastore.index(firstIndex.id); + const [metadata] = await index.getMetadata(); + assert.deepStrictEqual( + metadata, + firstIndex.metadata, + 'asked index is the same as received index', + ); + }); + }); + describe('importing and exporting entities', () => { + const gcs = new Storage(); + const bucket = gcs.bucket('nodejs-datastore-system-tests'); + let currentAttempt = 0; + const setupForDelay = () => { + currentAttempt++; + }; + const delay = async (test: Mocha.Context) => { + const retries = currentAttempt - 1; + if (retries === 0) return; // no retry on the first attempt. + // see: https://cloud.google.com/storage/docs/exponential-backoff: + const ms = Math.pow(2, retries) * 500 + Math.random() * 1000; + return new Promise(done => { + console.info( + `retrying "${test.test?.title}" after attempt ${currentAttempt} in ${ms}ms`, + ); + setTimeout(done, ms); + }); + }; + describe('running tests against the delay function', () => { + let consoleInfoFunction: (message: string) => void; + let infoLogCount = 0; + before(async () => { + infoLogCount = 0; + currentAttempt = 0; + consoleInfoFunction = console.info; + }); + it('should be sure that the delay function emits console info messages', async function () { + // Override console.info to track the number of times it is called. + console.info = (message: string) => { + infoLogCount++; + consoleInfoFunction(message); + }; + // Run code that will typically be used in any test with the delay function. + setupForDelay(); + const numberOfRetries = 2; + this.retries(numberOfRetries); + setImmediate(() => delay(this)); + // Throw an error on every retry except the last one + if (currentAttempt <= numberOfRetries) { + throw Error( + 'This is not the last retry so throw an error to force the test to run again', + ); + } + // Check that the attempt number and the number of times console.info is called is correct. + assert.strictEqual(infoLogCount, numberOfRetries - 1); + assert.strictEqual(currentAttempt, numberOfRetries + 1); + }); + after(async () => { + console.info = consoleInfoFunction; + }); + }); + it('should export, then import entities', async function () { + setupForDelay(); + this.retries(3); + await delay(this); + const [exportOperation] = await datastore.export({bucket}); + await exportOperation.promise(); + const [files] = await bucket.getFiles({maxResults: 1}); + const [exportedFile] = files; + assert.ok(exportedFile.name.includes('overall_export_metadata')); + const [importOperation] = await datastore.import({ + file: exportedFile, + }); + // This is a >20 minute operation, so we're just going to make sure the + // right type of operation was started. + assert.strictEqual( + ( + importOperation.metadata as google.datastore.admin.v1.IImportEntitiesMetadata + ).inputUrl, + `gs://${exportedFile.bucket.name}/${exportedFile.name}`, + ); + await importOperation.cancel(); + }); + }); + describe('using a custom endpoint', () => { + it('should complete a request when using the default endpoint as a custom endpoint', async () => { + const customDatastore = new Datastore({ + namespace: `${Date.now()}`, + apiEndpoint: 'datastore.googleapis.com', + }); + const query = customDatastore.createQuery('Kind').select('__key__'); + const [entities] = await customDatastore.runQuery(query); + assert.strictEqual(entities.length, 0); + }); + }); + describe('using the rest fallback parameter', () => { + it('should make a get call using rest instead of grpc', async () => { + const customDatastore = new Datastore({ + fallback: 'rest', + }); + const postKey = datastore.key(['Post', 'post1']); + const [entity] = await customDatastore.get(postKey); + assert.strictEqual(entity, undefined); + }); + }); + describe('Datastore mode data transforms', () => { + const key = datastore.key(['Post', 'post1']); + function getStandardTestCase() { + return { + name: 'should perform a basic data transform', + saveArg: { + key: key, + data: { + name: 'test', + p1: 3, + p2: 4, + p3: 5, + a1: [3, 4, 5], + }, + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + { + property: 'p2', + increment: 4, + }, + { + property: 'p3', + maximum: 9, + }, + { + property: 'p2', + minimum: 6, + }, + { + property: 'a1', + appendMissingElements: [5, 6], + }, + { + property: 'a1', + removeAllFromArray: [3], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '8', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '9', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '6', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [4, 5, 6], + p2: 6, + p3: 9, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '3', + }, + p2: { + integerValue: '4', + }, + p3: { + integerValue: '5', + }, + a1: { + arrayValue: { + values: [ + { + integerValue: '3', + }, + { + integerValue: '4', + }, + { + integerValue: '5', + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + { + property: 'p2', + increment: { + integerValue: '4', + }, + }, + { + property: 'p3', + maximum: { + integerValue: '9', + }, + }, + { + property: 'p2', + minimum: { + integerValue: '6', + }, + }, + { + property: 'a1', + appendMissingElements: { + values: [ + { + integerValue: '5', + }, + { + integerValue: '6', + }, + ], + }, + }, + { + property: 'a1', + removeAllFromArray: { + values: [ + { + integerValue: '3', + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + } + const standardTestCase = getStandardTestCase(); + // Add test case 2: Setting the server value to false: + const standardTestCaseWithSetToServerFalse = getStandardTestCase(); + standardTestCaseWithSetToServerFalse.name = + 'should perform a transform with setToServerValue false'; + standardTestCaseWithSetToServerFalse.saveArg.transforms.shift(); + standardTestCaseWithSetToServerFalse.saveResult[0].mutationResults[0].transformResults.shift(); + standardTestCaseWithSetToServerFalse.gapicRequest.reqOpts.mutations[0].propertyTransforms.shift(); + // Add test case 3: User inputs string values for transforms + const standardTestCaseWithStringValues = getStandardTestCase(); + standardTestCaseWithStringValues.name = + 'should perform a transform with string values'; + standardTestCaseWithStringValues.saveArg.transforms[1].increment = + '4' as any; + standardTestCaseWithStringValues.saveArg.transforms[2].maximum = + '9' as any; + standardTestCaseWithStringValues.saveArg.transforms[3].minimum = + '6' as any; + const setToServerValueBooleanTestCase = { + name: 'should perform a setToServerValue transform on a boolean property', + saveArg: { + key: key, + data: { + name: 'test', + p1: false, + }, + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + booleanValue: false, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const incrementFloatTestCase = { + name: 'should perform an increment transform on a float property', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + p1: 3.5, + }, + transforms: [ + { + property: 'p1', + increment: 1.2, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + doubleValue: 4.7, + valueType: 'doubleValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + p1: 4.7, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + doubleValue: 3.5, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + increment: { + doubleValue: 1.2, + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const appendMissingElementsComplexTestCase = { + name: 'should perform an appendMissingElements transform with complex objects', + saveArg: { + key: key, + data: { + name: 'test', + a1: [{a: 1, b: 'two'}], + }, + transforms: [ + { + property: 'a1', + appendMissingElements: [{a: 1, b: 'two'}, {c: 3}], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [{a: 1, b: 'two'}, {c: 3}], + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + a1: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'a1', + appendMissingElements: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + { + entityValue: { + properties: { + c: { + integerValue: '3', + }, + }, + }, + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const removeAllFromArrayComplexTestCase = { + name: 'should perform a removeAllFromArray transform with complex objects', + saveArg: { + key: key, + data: { + name: 'test', + a1: [{a: 1, b: 'two'}, {c: 3}], + }, + transforms: [ + { + property: 'a1', + removeAllFromArray: [{a: 1, b: 'two'}], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [{c: 3}], + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + a1: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + { + entityValue: { + properties: { + c: { + integerValue: '3', + }, + }, + }, + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'a1', + removeAllFromArray: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const orderOfOperationsTestCase = { + name: 'should respect the order of operations for transforms', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + p1: 5, + }, + transforms: [ + { + property: 'p1', + increment: 5, // p1 is now 10 + }, + { + property: 'p1', + maximum: 8, // p1 is now 8 + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '10', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '10', + valueType: 'integerValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + p1: 10, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '5', + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + increment: { + integerValue: '5', + }, + }, + { + property: 'p1', + maximum: { + integerValue: '8', + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const nestedPropertyTransformTestCase = { + name: 'should perform a transform on a nested property', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + nested: { + p1: 10, + }, + }, + transforms: [ + { + property: 'nested.p1', + increment: 5, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '15', + valueType: 'integerValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + nested: { + p1: 15, + }, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + nested: { + entityValue: { + properties: { + p1: { + integerValue: '10', + }, + }, + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'nested.p1', + increment: { + integerValue: '5', + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + // Test each of the test cases: + async.each( + [ + standardTestCase, + standardTestCaseWithSetToServerFalse, + standardTestCaseWithStringValues, + setToServerValueBooleanTestCase, + incrementFloatTestCase, + appendMissingElementsComplexTestCase, + removeAllFromArrayComplexTestCase, + orderOfOperationsTestCase, + nestedPropertyTransformTestCase, + ], + async (testParameters: any) => { + it(testParameters.name, async () => { + const requestSpy = sinon.spy(datastore.request_); + datastore.request_ = requestSpy; + const result = await datastore.save(testParameters.saveArg); + // Clean the data from the server first before comparing: + result.forEach(serverResult => { + delete serverResult['indexUpdates']; + serverResult.mutationResults?.forEach(mutationResult => { + delete mutationResult['updateTime']; + delete mutationResult['createTime']; + delete mutationResult['version']; + mutationResult.transformResults?.forEach(transformResult => { + delete transformResult['timestampValue']; + }); + }); + }); + // Now the data should have fixed values. + // Do a comparison against the expected result. + assert.deepStrictEqual(result, testParameters.saveResult); + // Now check the value that was actually saved to the server: + const [entity] = await datastore.get(key); + const parsedResult = JSON.parse(JSON.stringify(entity)); + if (!testParameters.assertP1) { + delete parsedResult['p1']; // This is a timestamp so we can't consistently test this. + } + assert.deepStrictEqual(parsedResult, testParameters.serverValue); + if ( + requestSpy.args[0][0].reqOpts.mutations[0].upsert.key + .partitionId + ) { + delete requestSpy.args[0][0].reqOpts.mutations[0].upsert.key + .partitionId['namespaceId']; + } + assert.deepStrictEqual( + requestSpy.args[0][0], + testParameters.gapicRequest, + ); + }); + }, + ); + }); + describe('Datastore mode data transforms in transactions', () => { + const mockedDatastore = new MockedDatastore(); + const key = mockedDatastore.key(['Post', 'post1']); + function getStandardTestCase() { + return { + name: 'should perform a basic data transform', + saveArg: { + key: key, + data: { + name: 'test', + p1: 3, + p2: 4, + p3: 5, + a1: [3, 4, 5], + }, + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + { + property: 'p2', + increment: 4, + }, + { + property: 'p3', + maximum: 9, + }, + { + property: 'p2', + minimum: 6, + }, + { + property: 'a1', + appendMissingElements: [5, 6], + }, + { + property: 'a1', + removeAllFromArray: [3], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '8', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '9', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '6', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [4, 5, 6], + p2: 6, + p3: 9, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '3', + }, + p2: { + integerValue: '4', + }, + p3: { + integerValue: '5', + }, + a1: { + arrayValue: { + values: [ + { + integerValue: '3', + }, + { + integerValue: '4', + }, + { + integerValue: '5', + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + { + property: 'p2', + increment: { + integerValue: '4', + }, + }, + { + property: 'p3', + maximum: { + integerValue: '9', + }, + }, + { + property: 'p2', + minimum: { + integerValue: '6', + }, + }, + { + property: 'a1', + appendMissingElements: { + values: [ + { + integerValue: '5', + }, + { + integerValue: '6', + }, + ], + }, + }, + { + property: 'a1', + removeAllFromArray: { + values: [ + { + integerValue: '3', + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + } + const standardTestCase = getStandardTestCase(); + // Add test case 2: Setting the server value to false: + const standardTestCaseWithSetToServerFalse = getStandardTestCase(); + standardTestCaseWithSetToServerFalse.name = + 'should perform a transform with setToServerValue false'; + standardTestCaseWithSetToServerFalse.saveArg.transforms.shift(); + standardTestCaseWithSetToServerFalse.saveResult[0].mutationResults[0].transformResults.shift(); + standardTestCaseWithSetToServerFalse.gapicRequest.reqOpts.mutations[0].propertyTransforms.shift(); + // Add test case 3: User inputs string values for transforms + const standardTestCaseWithStringValues = getStandardTestCase(); + standardTestCaseWithStringValues.name = + 'should perform a transform with string values'; + standardTestCaseWithStringValues.saveArg.transforms[1].increment = + '4' as any; + standardTestCaseWithStringValues.saveArg.transforms[2].maximum = + '9' as any; + standardTestCaseWithStringValues.saveArg.transforms[3].minimum = + '6' as any; + const setToServerValueBooleanTestCase = { + name: 'should perform a setToServerValue transform on a boolean property', + saveArg: { + key: key, + data: { + name: 'test', + p1: false, + }, + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + booleanValue: false, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const incrementFloatTestCase = { + name: 'should perform an increment transform on a float property', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + p1: 3.5, + }, + transforms: [ + { + property: 'p1', + increment: 1.2, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + doubleValue: 4.7, + valueType: 'doubleValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + p1: 4.7, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + doubleValue: 3.5, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + increment: { + doubleValue: 1.2, + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const appendMissingElementsComplexTestCase = { + name: 'should perform an appendMissingElements transform with complex objects', + saveArg: { + key: key, + data: { + name: 'test', + a1: [{a: 1, b: 'two'}], + }, + transforms: [ + { + property: 'a1', + appendMissingElements: [{a: 1, b: 'two'}, {c: 3}], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [{a: 1, b: 'two'}, {c: 3}], + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + name: { + stringValue: 'test', + }, + a1: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'a1', + appendMissingElements: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + { + entityValue: { + properties: { + c: { + integerValue: '3', + }, + }, + }, + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const removeAllFromArrayComplexTestCase = { + name: 'should perform a removeAllFromArray transform with complex objects', + saveArg: { + key: key, + data: { + name: 'test', + a1: [{a: 1, b: 'two'}, {c: 3}], + }, + transforms: [ + { + property: 'a1', + removeAllFromArray: [{a: 1, b: 'two'}], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [{c: 3}], + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + name: { + stringValue: 'test', + }, + a1: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + { + entityValue: { + properties: { + c: { + integerValue: '3', + }, + }, + }, + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'a1', + removeAllFromArray: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const orderOfOperationsTestCase = { + name: 'should respect the order of operations for transforms', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + p1: 5, + }, + transforms: [ + { + property: 'p1', + increment: 5, // p1 is now 10 + }, + { + property: 'p1', + maximum: 8, // p1 is now 8 + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '10', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '10', + valueType: 'integerValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + p1: 10, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '5', + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + increment: { + integerValue: '5', + }, + }, + { + property: 'p1', + maximum: { + integerValue: '8', + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const nestedPropertyTransformTestCase = { + name: 'should perform a transform on a nested property', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + nested: { + p1: 10, + }, + }, + transforms: [ + { + property: 'nested.p1', + increment: 5, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '15', + valueType: 'integerValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + nested: { + p1: 15, + }, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + name: { + stringValue: 'test', + }, + nested: { + entityValue: { + properties: { + p1: { + integerValue: '10', + }, + }, + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'nested.p1', + increment: { + integerValue: '5', + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + // Test each of the test cases: + async.each( + [ + standardTestCase, + standardTestCaseWithSetToServerFalse, + standardTestCaseWithStringValues, + setToServerValueBooleanTestCase, + incrementFloatTestCase, + appendMissingElementsComplexTestCase, + removeAllFromArrayComplexTestCase, + orderOfOperationsTestCase, + nestedPropertyTransformTestCase, + ], + async (testParameters: any) => { + it(testParameters.name, async () => { + testRequests.splice(0, testRequests.length); + const transaction = mockedDatastore.transaction(); + await transaction.run(); + transaction.save(testParameters.saveArg); + await transaction.commit(); + // Now check the value that was actually saved to the server: + testRequests.shift(); // Remove the BeginTransaction request. + const [entity] = await mockedDatastore.get(key); + const parsedResult = JSON.parse(JSON.stringify(entity)); + if (!testParameters.assertP1) { + delete parsedResult['p1']; // This is a timestamp so we can't consistently test this. + } + assert.deepStrictEqual(parsedResult, testParameters.serverValue); + assert(testRequests); + assert(testRequests[0]); + if ( + testRequests[0] && + testRequests[0].reqOpts?.mutations && + testRequests[0].reqOpts?.mutations[0] && + testRequests[0].reqOpts?.mutations[0].upsert?.key?.partitionId + ) { + delete testRequests[0].reqOpts.mutations[0].upsert.key + .partitionId['namespaceId']; + } + assert.deepStrictEqual( + testRequests[0], + testParameters.gapicRequest, + ); + }); + }, + ); + }); + describe('Datastore mode data transforms', () => { + const key = datastore.key(['Post', 'post1']); + function getStandardTestCase() { + return { + name: 'should perform a basic data transform', + saveArg: { + key: key, + data: { + name: 'test', + p1: 3, + p2: 4, + p3: 5, + a1: [3, 4, 5], + }, + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + { + property: 'p2', + increment: 4, + }, + { + property: 'p3', + maximum: 9, + }, + { + property: 'p2', + minimum: 6, + }, + { + property: 'a1', + appendMissingElements: [5, 6], + }, + { + property: 'a1', + removeAllFromArray: [3], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '8', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '9', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '6', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [4, 5, 6], + p2: 6, + p3: 9, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '3', + }, + p2: { + integerValue: '4', + }, + p3: { + integerValue: '5', + }, + a1: { + arrayValue: { + values: [ + { + integerValue: '3', + }, + { + integerValue: '4', + }, + { + integerValue: '5', + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + { + property: 'p2', + increment: { + integerValue: '4', + }, + }, + { + property: 'p3', + maximum: { + integerValue: '9', + }, + }, + { + property: 'p2', + minimum: { + integerValue: '6', + }, + }, + { + property: 'a1', + appendMissingElements: { + values: [ + { + integerValue: '5', + }, + { + integerValue: '6', + }, + ], + }, + }, + { + property: 'a1', + removeAllFromArray: { + values: [ + { + integerValue: '3', + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + } + const standardTestCase = getStandardTestCase(); + // Add test case 2: Setting the server value to false: + const standardTestCaseWithSetToServerFalse = getStandardTestCase(); + standardTestCaseWithSetToServerFalse.name = + 'should perform a transform with setToServerValue false'; + standardTestCaseWithSetToServerFalse.saveArg.transforms.shift(); + standardTestCaseWithSetToServerFalse.saveResult[0].mutationResults[0].transformResults.shift(); + standardTestCaseWithSetToServerFalse.gapicRequest.reqOpts.mutations[0].propertyTransforms.shift(); + // Add test case 3: User inputs string values for transforms + const standardTestCaseWithStringValues = getStandardTestCase(); + standardTestCaseWithStringValues.name = + 'should perform a transform with string values'; + standardTestCaseWithStringValues.saveArg.transforms[1].increment = + '4' as any; + standardTestCaseWithStringValues.saveArg.transforms[2].maximum = + '9' as any; + standardTestCaseWithStringValues.saveArg.transforms[3].minimum = + '6' as any; + const setToServerValueBooleanTestCase = { + name: 'should perform a setToServerValue transform on a boolean property', + saveArg: { + key: key, + data: { + name: 'test', + p1: false, + }, + transforms: [ + { + property: 'p1', + setToServerValue: true, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + valueType: 'timestampValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + booleanValue: false, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + setToServerValue: 1, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const incrementFloatTestCase = { + name: 'should perform an increment transform on a float property', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + p1: 3.5, + }, + transforms: [ + { + property: 'p1', + increment: 1.2, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + doubleValue: 4.7, + valueType: 'doubleValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + p1: 4.7, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + doubleValue: 3.5, + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + increment: { + doubleValue: 1.2, + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const appendMissingElementsComplexTestCase = { + name: 'should perform an appendMissingElements transform with complex objects', + saveArg: { + key: key, + data: { + name: 'test', + a1: [{a: 1, b: 'two'}], + }, + transforms: [ + { + property: 'a1', + appendMissingElements: [{a: 1, b: 'two'}, {c: 3}], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [{a: 1, b: 'two'}, {c: 3}], + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + a1: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'a1', + appendMissingElements: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + { + entityValue: { + properties: { + c: { + integerValue: '3', + }, + }, + }, + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const removeAllFromArrayComplexTestCase = { + name: 'should perform a removeAllFromArray transform with complex objects', + saveArg: { + key: key, + data: { + name: 'test', + a1: [{a: 1, b: 'two'}, {c: 3}], + }, + transforms: [ + { + property: 'a1', + removeAllFromArray: [{a: 1, b: 'two'}], + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + nullValue: 'NULL_VALUE', + valueType: 'nullValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + a1: [{c: 3}], + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + a1: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + { + entityValue: { + properties: { + c: { + integerValue: '3', + }, + }, + }, + }, + ], + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'a1', + removeAllFromArray: { + values: [ + { + entityValue: { + properties: { + a: { + integerValue: '1', + }, + b: { + stringValue: 'two', + }, + }, + }, + }, + ], + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const orderOfOperationsTestCase = { + name: 'should respect the order of operations for transforms', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + p1: 5, + }, + transforms: [ + { + property: 'p1', + increment: 5, // p1 is now 10 + }, + { + property: 'p1', + maximum: 8, // p1 is now 8 + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '10', + valueType: 'integerValue', + }, + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '10', + valueType: 'integerValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + p1: 10, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + p1: { + integerValue: '5', + }, + }, + }, + propertyTransforms: [ + { + property: 'p1', + increment: { + integerValue: '5', + }, + }, + { + property: 'p1', + maximum: { + integerValue: '8', + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + const nestedPropertyTransformTestCase = { + name: 'should perform a transform on a nested property', + assertP1: true, + saveArg: { + key: key, + data: { + name: 'test', + nested: { + p1: 10, + }, + }, + transforms: [ + { + property: 'nested.p1', + increment: 5, + }, + ], + }, + saveResult: [ + { + mutationResults: [ + { + transformResults: [ + { + meaning: 0, + excludeFromIndexes: false, + integerValue: '15', + valueType: 'integerValue', + }, + ], + key: null, + conflictDetected: false, + }, + ], + commitTime: null, + }, + ], + serverValue: { + name: 'test', + nested: { + p1: 15, + }, + }, + gapicRequest: { + client: 'DatastoreClient', + method: 'commit', + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + partitionId: {}, + }, + properties: { + name: { + stringValue: 'test', + }, + nested: { + entityValue: { + properties: { + p1: { + integerValue: '10', + }, + }, + }, + }, + }, + }, + propertyTransforms: [ + { + property: 'nested.p1', + increment: { + integerValue: '5', + }, + }, + ], + }, + ], + }, + gaxOpts: {}, + }, + }; + // Test each of the test cases: + async.each( + [ + standardTestCase, + standardTestCaseWithSetToServerFalse, + standardTestCaseWithStringValues, + setToServerValueBooleanTestCase, + incrementFloatTestCase, + appendMissingElementsComplexTestCase, + removeAllFromArrayComplexTestCase, + orderOfOperationsTestCase, + nestedPropertyTransformTestCase, + ], + async (testParameters: any) => { + it(testParameters.name, async () => { + const requestSpy = sinon.spy(datastore.request_); + datastore.request_ = requestSpy; + const result = await datastore.save(testParameters.saveArg); + // Clean the data from the server first before comparing: + result.forEach(serverResult => { + delete serverResult['indexUpdates']; + serverResult.mutationResults?.forEach(mutationResult => { + delete mutationResult['updateTime']; + delete mutationResult['createTime']; + delete mutationResult['version']; + mutationResult.transformResults?.forEach(transformResult => { + delete transformResult['timestampValue']; + }); + }); + }); + // Now the data should have fixed values. + // Do a comparison against the expected result. + assert.deepStrictEqual(result, testParameters.saveResult); + // Now check the value that was actually saved to the server: + const [entity] = await datastore.get(key); + const parsedResult = JSON.parse(JSON.stringify(entity)); + if (!testParameters.assertP1) { + delete parsedResult['p1']; // This is a timestamp so we can't consistently test this. + } + assert.deepStrictEqual(parsedResult, testParameters.serverValue); + if ( + requestSpy.args[0][0].reqOpts.mutations[0].upsert.key + .partitionId + ) { + delete requestSpy.args[0][0].reqOpts.mutations[0].upsert.key + .partitionId['namespaceId']; + } + assert.deepStrictEqual( + requestSpy.args[0][0], + testParameters.gapicRequest, + ); + }); + }, + ); + }); + }); + }, +); diff --git a/handwritten/nodejs-datastore/system-test/fixtures/sample/src/index.js b/handwritten/nodejs-datastore/system-test/fixtures/sample/src/index.js new file mode 100644 index 00000000000..d9da9fb4527 --- /dev/null +++ b/handwritten/nodejs-datastore/system-test/fixtures/sample/src/index.js @@ -0,0 +1,27 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 datastore = require('@google-cloud/datastore'); + +function main() { + const datastoreClient = new datastore.Datastore(); +} + +main(); diff --git a/handwritten/nodejs-datastore/system-test/fixtures/sample/src/index.ts b/handwritten/nodejs-datastore/system-test/fixtures/sample/src/index.ts new file mode 100644 index 00000000000..c0c27e781f1 --- /dev/null +++ b/handwritten/nodejs-datastore/system-test/fixtures/sample/src/index.ts @@ -0,0 +1,32 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 {Datastore} from '@google-cloud/datastore'; + +// check that the client class type name can be used +function doStuffWithDatastore(client: Datastore) { + // client.close(); +} + +function main() { + // check that the client instance can be created + const datastoreClient = new Datastore(); + doStuffWithDatastore(datastoreClient); +} + +main(); diff --git a/handwritten/nodejs-datastore/system-test/fixtures/sample/src/long.d.ts b/handwritten/nodejs-datastore/system-test/fixtures/sample/src/long.d.ts new file mode 100644 index 00000000000..c9aa59ed400 --- /dev/null +++ b/handwritten/nodejs-datastore/system-test/fixtures/sample/src/long.d.ts @@ -0,0 +1 @@ +declare module 'long'; diff --git a/handwritten/nodejs-datastore/system-test/install.ts b/handwritten/nodejs-datastore/system-test/install.ts new file mode 100644 index 00000000000..96de8bb3e3f --- /dev/null +++ b/handwritten/nodejs-datastore/system-test/install.ts @@ -0,0 +1,54 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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(), + dependencies: [ + '@types/long@^4.0.0', + ], + }, + }; + 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/handwritten/nodejs-datastore/system-test/transaction-spy.ts b/handwritten/nodejs-datastore/system-test/transaction-spy.ts new file mode 100644 index 00000000000..23ea7a69524 --- /dev/null +++ b/handwritten/nodejs-datastore/system-test/transaction-spy.ts @@ -0,0 +1,42 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as proxyquire from 'proxyquire'; +import {DatastoreRequest} from '../src'; +import {RequestCallback, RequestConfig} from '../src/request'; + +const testRequests: RequestConfig[] = []; + +class RequestsMock extends DatastoreRequest { + request_(config: RequestConfig, callback: RequestCallback): void { + testRequests.push(config); + super.request_(config, callback); + } +} + +// Mock Transaction class +const MockTransaction = proxyquire('../src/transaction', { + './request': { + DatastoreRequest: RequestsMock, + }, +}).Transaction; + +// Use proxyquire to mock the Datastore class +const MockedDatastore = proxyquire('../src', { + './transaction': { + Transaction: MockTransaction, + }, +}).Datastore; + +export {MockedDatastore, MockTransaction, testRequests}; diff --git a/handwritten/nodejs-datastore/test/entity.ts b/handwritten/nodejs-datastore/test/entity.ts new file mode 100644 index 00000000000..2d406057335 --- /dev/null +++ b/handwritten/nodejs-datastore/test/entity.ts @@ -0,0 +1,1837 @@ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as assert from 'assert'; +import {beforeEach, afterEach, describe, it} from 'mocha'; +import * as extend from 'extend'; +import * as sinon from 'sinon'; +import {Datastore} from '../src'; +import {Entity, entity} from '../src/entity'; +import {IntegerTypeCastOptions} from '../src/query'; +import {PropertyFilter, EntityFilter, and} from '../src/filter'; +import { + entityObject, + expectedEntityProto, +} from './fixtures/entityObjectAndProto'; + +export function outOfBoundsError(opts: { + propertyName?: string; + integerValue: string | number; +}) { + return new Error( + 'We attempted to return all of the numeric values, but ' + + (opts.propertyName ? opts.propertyName + ' ' : '') + + 'value ' + + opts.integerValue + + " is out of bounds of 'Number.MAX_SAFE_INTEGER'.\n" + + "To prevent this error, please consider passing 'options.wrapNumbers=true' or\n" + + "'options.wrapNumbers' as\n" + + '{\n' + + ' integerTypeCastFunction: provide \n' + + ' properties: optionally specify property name(s) to be custom casted\n' + + '}\n', + ); +} + +describe('entity', () => { + let testEntity: Entity; + + beforeEach(() => { + delete require.cache[require.resolve('../src/entity.js')]; + testEntity = require('../src/entity.js').entity; + }); + + describe('KEY_SYMBOL', () => { + it('should export the symbol', () => { + assert.strictEqual(testEntity.KEY_SYMBOL.toString(), 'Symbol(KEY)'); + }); + }); + + describe('Double', () => { + it('should store the value', () => { + const value = 8.3; + + const double = new testEntity.Double(value); + assert.strictEqual(double.value, value); + }); + }); + + describe('isDsDouble', () => { + it('should correctly identify a Double', () => { + const double = new testEntity.Double(0.42); + assert.strictEqual(testEntity.isDsDouble(double), true); + }); + + it('should correctly identify a homomorphic non-Double', () => { + const nonDouble = Object.assign({}, new testEntity.Double(42)); + assert.strictEqual(testEntity.isDsDouble(nonDouble), false); + }); + + it('should correctly identify a primitive', () => { + const primitiveDouble = 0.42; + assert.strictEqual(testEntity.isDsDouble(primitiveDouble), false); + }); + }); + + describe('isDsDoubleLike', () => { + it('should correctly identify a Double', () => { + const double = new testEntity.Double(0.42); + assert.strictEqual(testEntity.isDsDoubleLike(double), true); + }); + + it('should correctly identify a POJO Double', () => { + const double = new testEntity.Double(0.42); + const pojoDouble = JSON.parse(JSON.stringify(double)); + assert.strictEqual(testEntity.isDsDoubleLike(pojoDouble), true); + }); + }); + + describe('Int', () => { + it('should store the stringified value', () => { + const value = 8; + + const int = new testEntity.Int(value); + assert.strictEqual(int.value, value.toString()); + }); + + it('should store the stringified value from valueProto object', () => { + const valueProto = { + valueType: 'integerValue', + integerValue: 8, + }; + const int = new testEntity.Int(valueProto); + assert.strictEqual(int.value, valueProto.integerValue.toString()); + }); + + describe('valueOf', () => { + let valueProto: {}; + beforeEach(() => { + valueProto = { + valueType: 'integerValue', + integerValue: 8, + }; + }); + + describe('integerTypeCastFunction is not provided', () => { + it('should throw if integerTypeCastOptions is provided but integerTypeCastFunction is not', () => { + assert.throws( + () => new testEntity.Int(valueProto, {}).valueOf(), + /integerTypeCastFunction is not a function or was not provided\./, + ); + }); + + it('should throw if integer value is outside of bounds passing objects', () => { + const largeIntegerValue = Number.MAX_SAFE_INTEGER + 1; + const smallIntegerValue = Number.MIN_SAFE_INTEGER - 1; + + const valueProto = { + integerValue: largeIntegerValue, + propertyName: 'phoneNumber', + }; + + const valueProto2 = { + integerValue: smallIntegerValue, + propertyName: 'phoneNumber', + }; + + assert.throws(() => { + new testEntity.Int(valueProto).valueOf(); + }, outOfBoundsError(valueProto)); + + assert.throws(() => { + new testEntity.Int(valueProto2).valueOf(); + }, outOfBoundsError(valueProto2)); + }); + + it('should throw if integer value is outside of bounds passing strings or Numbers', () => { + const largeIntegerValue = Number.MAX_SAFE_INTEGER + 1; + const smallIntegerValue = Number.MIN_SAFE_INTEGER - 1; + + // should throw when Number is passed + assert.throws( + () => { + new testEntity.Int(largeIntegerValue).valueOf(); + }, + outOfBoundsError({integerValue: largeIntegerValue}), + ); + + // should throw when string is passed + assert.throws( + () => { + new testEntity.Int(smallIntegerValue.toString()).valueOf(); + }, + outOfBoundsError({integerValue: smallIntegerValue}), + ); + }); + + it('should not auto throw on initialization', () => { + const largeIntegerValue = Number.MAX_SAFE_INTEGER + 1; + + const valueProto = { + valueType: 'integerValue', + integerValue: largeIntegerValue, + }; + + assert.doesNotThrow( + () => { + new testEntity.Int(valueProto); + }, + new RegExp(`Integer value ${largeIntegerValue} is out of bounds.`), + ); + }); + }); + + describe('integerTypeCastFunction is provided', () => { + it('should throw if integerTypeCastFunction is not a function', () => { + assert.throws( + () => + new testEntity.Int(valueProto, { + integerTypeCastFunction: {}, + }).valueOf(), + /integerTypeCastFunction is not a function or was not provided\./, + ); + }); + + it('should custom-cast integerValue when integerTypeCastFunction is provided', () => { + const stub = sinon.stub(); + + new testEntity.Int(valueProto, { + integerTypeCastFunction: stub, + }).valueOf(); + assert.ok(stub.calledOnce); + }); + + it('should custom-cast integerValue if `properties` specified by user', () => { + const stub = sinon.stub(); + Object.assign(valueProto, { + propertyName: 'thisValue', + }); + + new testEntity.Int(valueProto, { + integerTypeCastFunction: stub, + properties: 'thisValue', + }).valueOf(); + assert.ok(stub.calledOnce); + }); + + it('should not custom-cast integerValue if `properties` not specified by user', () => { + const stub = sinon.stub(); + + Object.assign(valueProto, { + propertyName: 'thisValue', + }); + + new testEntity.Int(valueProto, { + integerTypeCastFunction: stub, + properties: 'thatValue', + }).valueOf(); + assert.ok(stub.notCalled); + }); + }); + }); + }); + + describe('isDsInt', () => { + it('should correctly identify an Int', () => { + const int = new testEntity.Int(42); + assert.strictEqual(testEntity.isDsInt(int), true); + }); + + it('should correctly identify homomorphic non-Int', () => { + const nonInt = Object.assign({}, new testEntity.Int(42)); + assert.strictEqual(testEntity.isDsInt(nonInt), false); + }); + + it('should correctly identify a primitive', () => { + const primitiveInt = 42; + assert.strictEqual(testEntity.isDsInt(primitiveInt), false); + }); + }); + + describe('isDsIntLike', () => { + it('should correctly identify an Int', () => { + const int = new testEntity.Int(42); + assert.strictEqual(testEntity.isDsIntLike(int), true); + }); + + it('should correctly identify a POJO Int', () => { + const int = new testEntity.Int(42); + const pojoInt = JSON.parse(JSON.stringify(int)); + assert.strictEqual(testEntity.isDsIntLike(pojoInt), true); + }); + }); + + describe('GeoPoint', () => { + it('should store the value', () => { + const value = { + latitude: 24, + longitude: 88, + }; + + const geoPoint = new testEntity.GeoPoint(value); + assert.strictEqual(geoPoint.value, value); + }); + }); + + describe('isDsGeoPoint', () => { + it('should correctly identify a GeoPoint', () => { + const geoPoint = new testEntity.GeoPoint({latitude: 24, longitude: 88}); + assert.strictEqual(testEntity.isDsGeoPoint(geoPoint), true); + }); + + it('should correctly identify a homomorphic non-GeoPoint', () => { + const geoPoint = new testEntity.GeoPoint({latitude: 24, longitude: 88}); + const nonGeoPoint = Object.assign({}, geoPoint); + assert.strictEqual(testEntity.isDsGeoPoint(nonGeoPoint), false); + }); + }); + + describe('Key', () => { + it('should assign the namespace', () => { + const namespace = 'NS'; + const key = new testEntity.Key({namespace, path: []}); + assert.strictEqual(key.namespace, namespace); + }); + + it('should assign the kind', () => { + const kind = 'kind'; + const key = new testEntity.Key({path: [kind]}); + assert.strictEqual(key.kind, kind); + }); + + it('should assign the ID', () => { + const id = 11; + const key = new testEntity.Key({path: ['Kind', id]}); + assert.strictEqual(key.id, id); + }); + + it('should assign the ID from an Int', () => { + const id = new testEntity.Int(11); + const key = new testEntity.Key({path: ['Kind', id]}); + assert.strictEqual(key.id, id.value); + }); + + it('should assign the name', () => { + const name = 'name'; + const key = new testEntity.Key({path: ['Kind', name]}); + assert.strictEqual(key.name, name); + }); + + it('should assign a parent', () => { + const key = new testEntity.Key({path: ['ParentKind', 1, 'Kind', 1]}); + assert(key.parent instanceof testEntity.Key); + }); + + it('should not modify input path', () => { + const inputPath = ['ParentKind', 1, 'Kind', 1]; + new testEntity.Key({path: inputPath}); + assert.deepStrictEqual(inputPath, ['ParentKind', 1, 'Kind', 1]); + }); + + it('should always compute the correct path', () => { + const key = new testEntity.Key({path: ['ParentKind', 1, 'Kind', 1]}); + assert.deepStrictEqual(key.path, ['ParentKind', 1, 'Kind', 1]); + + key.parent.kind = 'GrandParentKind'; + key.kind = 'ParentKind'; + + assert.deepStrictEqual(key.path, ['GrandParentKind', 1, 'ParentKind', 1]); + }); + + it('should always compute the correct serialized path', () => { + const key = new testEntity.Key({ + namespace: 'namespace', + path: [ + 'ParentKind', + 'name', + 'Kind', + 1, + 'SubKind', + new testEntity.Int('1'), + ], + }); + assert.deepStrictEqual(key.serialized, { + namespace: 'namespace', + path: [ + 'ParentKind', + 'name', + 'Kind', + new testEntity.Int(1), + 'SubKind', + new testEntity.Int('1'), + ], + }); + }); + + it('should allow re-creating a Key from the serialized path', () => { + const key = new testEntity.Key({ + path: [ + 'ParentKind', + 'name', + 'Kind', + 1, + 'SubKind', + new testEntity.Int('1'), + ], + }); + const key2 = new testEntity.Key(key.serialized); + assert.deepStrictEqual(key.serialized, key2.serialized); + }); + + it('should allow re-creating a Key from the JSON serialized path', () => { + const key = new testEntity.Key({ + path: [ + 'ParentKind', + 'name', + 'Kind', + 1, + 'SubKind', + new testEntity.Int('1'), + ], + }); + const toPOJO = (v: object) => JSON.parse(JSON.stringify(v)); + const key2 = new testEntity.Key(toPOJO(key.serialized)); + assert.deepStrictEqual(key.serialized, key2.serialized); + }); + }); + + describe('isDsKey', () => { + it('should correctly identify a Key', () => { + const key = new testEntity.Key({path: ['Kind', 1]}); + assert.strictEqual(testEntity.isDsKey(key), true); + }); + + it('should correctly identify a homomorphic non-Key', () => { + const notKey = Object.assign({}, new testEntity.Key({path: ['Kind', 1]})); + assert.strictEqual(testEntity.isDsKey(notKey), false); + }); + }); + + describe('decodeValueProto', () => { + describe('arrays', () => { + const intValue = 8; + const expectedValue = [ + { + valueType: 'integerValue', + integerValue: intValue, + }, + ]; + const valueProto = { + valueType: 'arrayValue', + arrayValue: { + values: expectedValue, + }, + }; + + it('should decode arrays', () => { + const expectedValue = [{}]; + + const valueProto = { + valueType: 'arrayValue', + arrayValue: { + values: expectedValue, + }, + }; + + let run = false; + + const decodeValueProto = testEntity.decodeValueProto; + testEntity.decodeValueProto = (valueProto: {}) => { + if (!run) { + run = true; + return decodeValueProto(valueProto); + } + + assert.strictEqual(valueProto, expectedValue[0]); + return valueProto; + }; + + assert.deepStrictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + + it('should not wrap numbers by default', () => { + const decodeValueProto = testEntity.decodeValueProto; + testEntity.decodeValueProto = ( + valueProto: {}, + wrapNumbers?: boolean | {}, + ) => { + assert.strictEqual(wrapNumbers, undefined); + + return decodeValueProto(valueProto, wrapNumbers); + }; + + assert.deepStrictEqual(testEntity.decodeValueProto(valueProto), [ + intValue, + ]); + }); + + it('should wrap numbers with an option', () => { + const wrapNumbersBoolean = true; + const wrapNumbersObject = {}; + const decodeValueProto = testEntity.decodeValueProto; + let run = false; + testEntity.decodeValueProto = ( + valueProto: {}, + wrapNumbers?: boolean | {}, + ) => { + if (!run) { + run = true; + return decodeValueProto(valueProto, wrapNumbers); + } + + // verify that `wrapNumbers`param is passed (boolean or object) + assert.ok(wrapNumbers); + return valueProto; + }; + + assert.deepStrictEqual( + testEntity.decodeValueProto(valueProto, wrapNumbersBoolean), + expectedValue, + ); + + // reset the run flag. + run = false; + assert.deepStrictEqual( + testEntity.decodeValueProto(valueProto, wrapNumbersObject), + expectedValue, + ); + }); + }); + + describe('entities', () => { + it('should decode entities', () => { + const expectedValue = {}; + + const valueProto = { + valueType: 'entityValue', + entityValue: expectedValue, + }; + + testEntity.entityFromEntityProto = (entityProto: {}) => { + assert.strictEqual(entityProto, expectedValue); + return expectedValue; + }; + + assert.strictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + + it('should not wrap numbers by default', () => { + const expectedValue = {}; + + const valueProto = { + valueType: 'entityValue', + entityValue: expectedValue, + }; + + testEntity.entityFromEntityProto = ( + entityProto: {}, + wrapNumbers?: boolean | {}, + ) => { + assert.strictEqual(wrapNumbers, undefined); + assert.strictEqual(entityProto, expectedValue); + return expectedValue; + }; + + assert.strictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + + it('should wrap numbers with an option', () => { + const expectedValue = {}; + const wrapNumbersBoolean = true; + const wrapNumbersObject = {}; + + const valueProto = { + valueType: 'entityValue', + entityValue: expectedValue, + }; + + testEntity.entityFromEntityProto = ( + entityProto: {}, + wrapNumbers?: boolean | {}, + ) => { + // verify that `wrapNumbers`param is passed (boolean or object) + assert.ok(wrapNumbers); + assert.strictEqual(entityProto, expectedValue); + return expectedValue; + }; + + assert.strictEqual( + testEntity.decodeValueProto(valueProto, wrapNumbersBoolean), + expectedValue, + ); + + assert.strictEqual( + testEntity.decodeValueProto(valueProto, wrapNumbersObject), + expectedValue, + ); + }); + }); + + describe('integerValues', () => { + const valueProto = { + valueType: 'integerValue', + integerValue: 8, + }; + + describe('default `wrapNumbers: undefined`', () => { + it('should not wrap ints by default', () => { + assert.strictEqual( + typeof testEntity.decodeValueProto(valueProto), + 'number', + ); + }); + + it('should throw if integer value is outside of bounds', () => { + const largeIntegerValue = Number.MAX_SAFE_INTEGER + 1; + const smallIntegerValue = Number.MIN_SAFE_INTEGER - 1; + + const valueProto = { + valueType: 'integerValue', + integerValue: largeIntegerValue, + propertyName: 'phoneNumber', + }; + + const valueProto2 = { + valueType: 'integerValue', + integerValue: smallIntegerValue, + propertyName: 'phoneNumber', + }; + + assert.throws(() => { + testEntity.decodeValueProto(valueProto); + }, outOfBoundsError(valueProto)); + + assert.throws(() => { + testEntity.decodeValueProto(valueProto2); + }, outOfBoundsError(valueProto2)); + }); + }); + + describe('should wrap ints with option', () => { + it('should wrap ints with wrapNumbers as boolean', () => { + const wrapNumbers = true; + const stub = sinon.spy(testEntity, 'Int'); + + testEntity.decodeValueProto(valueProto, wrapNumbers); + assert.strictEqual(stub.called, true); + }); + + it('should wrap ints with wrapNumbers as object', () => { + const wrapNumbers = {integerTypeCastFunction: () => {}}; + const stub = sinon.spy(testEntity, 'Int'); + + testEntity.decodeValueProto(valueProto, wrapNumbers); + assert.strictEqual(stub.called, true); + }); + + it('should call #valueOf if integerTypeCastFunction is provided', () => { + Object.assign(valueProto, {integerValue: Number.MAX_SAFE_INTEGER}); + const takeFirstTen = sinon + .stub() + .callsFake((value: string) => value.toString().substr(0, 10)); + const wrapNumbers = {integerTypeCastFunction: takeFirstTen}; + + assert.strictEqual( + testEntity.decodeValueProto(valueProto, wrapNumbers), + takeFirstTen(Number.MAX_SAFE_INTEGER), + ); + assert.strictEqual(takeFirstTen.called, true); + }); + + it('should propagate error from typeCastfunction', () => { + const errorMessage = 'some error from type casting function'; + const error = new Error(errorMessage); + const stub = sinon.stub().throws(error); + assert.throws( + () => + testEntity + .decodeValueProto(valueProto, { + integerTypeCastFunction: stub, + }) + .valueOf(), + (err: Error) => { + return new RegExp( + `integerTypeCastFunction threw an error:\n\n - ${errorMessage}`, + ).test(err.message); + }, + ); + }); + }); + }); + + it('should decode blobs', () => { + const expectedValue = Buffer.from('Hi'); + + const valueProto = { + valueType: 'blobValue', + blobValue: expectedValue.toString('base64'), + }; + + assert.deepStrictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + + it('should decode null', () => { + const expectedValue = null; + + const valueProto = { + valueType: 'nullValue', + nullValue: 0, + }; + + const decodedValue = testEntity.decodeValueProto(valueProto); + assert.deepStrictEqual(decodedValue, expectedValue); + }); + + it('should decode doubles', () => { + const expectedValue = 8.3; + + const valueProto = { + valueType: 'doubleValue', + doubleValue: expectedValue, + }; + + assert.strictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + + it('should decode keys', () => { + const expectedValue = {}; + + const valueProto = { + valueType: 'keyValue', + keyValue: expectedValue, + }; + + testEntity.keyFromKeyProto = (keyProto: {}) => { + assert.strictEqual(keyProto, expectedValue); + return expectedValue; + }; + + assert.strictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + + it('should decode timestamps', () => { + const date = new Date(); + + const seconds = Math.floor(date.getTime() / 1000); + const ms = date.getMilliseconds(); + + const expectedValue = new Date(seconds * 1000 + ms); + + const valueProto = { + valueType: 'timestampValue', + timestampValue: { + seconds, + nanos: ms * 1e6, + }, + }; + + assert.deepStrictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + + it('should return the value if no conversions are necessary', () => { + const expectedValue = false; + + const valueProto = { + valueType: 'booleanValue', + booleanValue: expectedValue, + }; + + assert.strictEqual( + testEntity.decodeValueProto(valueProto), + expectedValue, + ); + }); + }); + + describe('encodeValue', () => { + it('should encode a boolean', () => { + const value = true; + + const expectedValueProto = { + booleanValue: value, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode null', () => { + const value = null; + + const expectedValueProto = { + nullValue: 0, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode an int', () => { + const value = 8; + + const expectedValueProto = { + integerValue: value, + }; + + testEntity.Int = function (value_: {}) { + assert.strictEqual(value_, value); + this.value = value_; + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should emit warning on out of bounce int', done => { + // eslint-disable-next-line @typescript-eslint/no-loss-of-precision + const largeIntValue = 9223372036854775807; + const property = 'largeInt'; + const expectedWarning = + 'IntegerOutOfBoundsWarning: ' + + "the value for '" + + property + + "' property is outside of bounds of a JavaScript Number.\n" + + "Use 'Datastore.int()' to preserve accuracy during the upload."; + + const onWarning = (warning: {message: unknown}) => { + assert.strictEqual(warning.message, expectedWarning); + process.removeListener('warning', onWarning); + done(); + }; + process.on('warning', onWarning); + testEntity.encodeValue(largeIntValue, property); + }); + + it('should encode an Int object', () => { + const value = new testEntity.Int(3); + + const expectedValueProto = { + integerValue: value.value, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode a double', () => { + const value = 8.3; + + const expectedValueProto = { + doubleValue: value, + }; + + testEntity.Double = function (value_: {}) { + assert.strictEqual(value_, value); + this.value = value_; + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode a Double object', () => { + const value = new testEntity.Double(3); + + const expectedValueProto = { + doubleValue: value.value, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode a GeoPoint object', () => { + const value = new testEntity.GeoPoint(); + + const expectedValueProto = { + geoPointValue: value.value, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode a date', () => { + const value = new Date(); + const seconds = value.getTime() / 1000; + + const expectedValueProto = { + timestampValue: { + seconds: Math.floor(seconds), + nanos: value.getMilliseconds() * 1e6, + }, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode a string', () => { + const value = 'Hi'; + + const expectedValueProto = { + stringValue: value, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode a buffer', () => { + const value = Buffer.from('Hi'); + + const expectedValueProto = { + blobValue: value, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode an array', () => { + const value = [{}]; + + const expectedValueProto = { + arrayValue: { + values: value, + }, + }; + + let run = false; + + const encodeValue = testEntity.encodeValue; + testEntity.encodeValue = (value_: {}) => { + if (!run) { + run = true; + return encodeValue(value_); + } + + assert.strictEqual(value_, value[0]); + return value_; + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode a Key', () => { + const value = new testEntity.Key({ + namespace: 'ns', + path: ['Kind', 1], + }); + + const expectedValueProto = { + keyValue: value, + }; + + testEntity.keyToKeyProto = (key: {}) => { + assert.strictEqual(key, value); + return value; + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should encode an object', () => { + const value = { + key: 'value', + }; + + const expectedValueProto = { + entityValue: { + properties: { + key: value.key, + }, + }, + }; + + let run = false; + + const encodeValue = testEntity.encodeValue; + testEntity.encodeValue = (value_: {}) => { + if (!run) { + run = true; + return encodeValue(value_); + } + + assert.strictEqual(value_, value.key); + return value_; + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should clone an object', () => { + const value = { + a: { + b: { + obj: true, + }, + }, + }; + + const originalValue = extend(true, {}, value); + + const encodedValue = testEntity.encodeValue(value); + + assert.deepStrictEqual(value, originalValue); + assert.notStrictEqual(value, encodedValue); + }); + + it('should encode an empty object', () => { + const value = {}; + + const expectedValueProto = { + entityValue: { + properties: {}, + }, + }; + + assert.deepStrictEqual(testEntity.encodeValue(value), expectedValueProto); + }); + + it('should throw if an invalid value was provided', () => { + assert.throws(() => { + testEntity.encodeValue(); + }, /Unsupported field value/); + }); + }); + + describe('entityFromEntityProto', () => { + it('should convert entity proto to entity', () => { + const expectedEntity = { + name: 'Stephen', + }; + + const entityProto = { + properties: { + name: { + valueType: 'stringValue', + stringValue: expectedEntity.name, + }, + }, + }; + + assert.deepStrictEqual( + testEntity.entityFromEntityProto(entityProto), + expectedEntity, + ); + }); + + describe('should pass `wrapNumbers` to decodeValueProto', () => { + const entityProto = {properties: {number: {}}}; + let decodeValueProtoStub: sinon.SinonStub; + let wrapNumbers: boolean | IntegerTypeCastOptions | undefined; + + beforeEach(() => { + decodeValueProtoStub = sinon.stub(testEntity, 'decodeValueProto'); + }); + + afterEach(() => { + decodeValueProtoStub.restore(); + }); + + it('should identify entity propertyName', () => { + testEntity.entityFromEntityProto(entityProto); + const valueProto = decodeValueProtoStub.getCall(0).args[0]; + assert.strictEqual(valueProto.propertyName, 'number'); + }); + + it('should pass `wrapNumbers` to decodeValueProto as undefined by default', () => { + testEntity.entityFromEntityProto(entityProto); + wrapNumbers = decodeValueProtoStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbers, undefined); + }); + + it('should pass `wrapNumbers` to decodeValueProto as boolean', () => { + testEntity.entityFromEntityProto(entityProto, true); + wrapNumbers = decodeValueProtoStub.getCall(0).args[1]; + assert.strictEqual(typeof wrapNumbers, 'boolean'); + }); + + it('should pass `wrapNumbers` to decodeValueProto as IntegerTypeCastOptions', () => { + const integerTypeCastOptions = { + integerTypeCastFunction: () => {}, + properties: 'that', + }; + + testEntity.entityFromEntityProto(entityProto, integerTypeCastOptions); + wrapNumbers = decodeValueProtoStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbers, integerTypeCastOptions); + assert.deepStrictEqual(wrapNumbers, integerTypeCastOptions); + }); + }); + }); + + describe('entityToEntityProto', () => { + it('should format an entity', () => { + const value = 'Stephen'; + + const entityObject = { + data: { + name: value, + }, + }; + + const expectedEntityProto = { + key: null, + properties: entityObject.data, + }; + + testEntity.encodeValue = (value_: {}) => { + assert.strictEqual(value_, value); + return value; + }; + + assert.deepStrictEqual( + testEntity.entityToEntityProto(entityObject), + expectedEntityProto, + ); + }); + + it('should respect excludeFromIndexes', () => { + assert.deepStrictEqual( + testEntity.entityToEntityProto(entityObject), + expectedEntityProto, + ); + }); + + it('should not throw when `null` value is supplied for a field with an entity/array index exclusion', () => { + const entityObject = { + excludeFromIndexes: [ + 'entityCompletelyExcluded.*', + 'entityPropertyExcluded.name', + 'entityArrayCompletelyExcluded[].*', + 'entityArrayPropertyExcluded[].name', + ], + + data: { + entityCompletelyExcluded: null, + entityPropertyExcluded: null, + entityArrayCompletelyExcluded: null, + entityArrayPropertyExcluded: null, + }, + }; + + const expectedEntityProto = { + key: null, + properties: { + entityCompletelyExcluded: { + nullValue: 0, + excludeFromIndexes: true, + }, + entityPropertyExcluded: { + nullValue: 0, + }, + entityArrayCompletelyExcluded: { + nullValue: 0, + }, + entityArrayPropertyExcluded: { + nullValue: 0, + }, + }, + }; + + assert.deepStrictEqual( + testEntity.entityToEntityProto(entityObject), + expectedEntityProto, + ); + }); + }); + + describe('formatArray', () => { + it('should convert protos to key/data entity array', () => { + const key = {}; + + const entityProto = { + key, + }; + + const results = [ + { + entity: entityProto, + }, + ]; + + const expectedResults = entityProto; + + testEntity.keyFromKeyProto = (key_: {}) => { + assert.strictEqual(key_, key); + return key; + }; + + testEntity.entityFromEntityProto = (entityProto_: {}) => { + assert.strictEqual(entityProto_, entityProto); + return entityProto; + }; + + const ent = testEntity.formatArray(results)[0]; + + assert.deepStrictEqual(ent, expectedResults); + }); + + describe('should pass `wrapNumbers` to entityFromEntityProto', () => { + const results = [{entity: {}}]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let entityFromEntityProtoStub: any; + let wrapNumbers: boolean | IntegerTypeCastOptions | undefined; + + beforeEach(() => { + entityFromEntityProtoStub = sinon + .stub(testEntity, 'entityFromEntityProto') + .callsFake(() => ({})); + sinon.stub(testEntity, 'keyFromKeyProto'); + }); + + afterEach(() => { + entityFromEntityProtoStub.restore(); + }); + + it('should pass `wrapNumbers` to entityFromEntityProto as undefined by default', () => { + testEntity.formatArray(results); + wrapNumbers = entityFromEntityProtoStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbers, undefined); + }); + + it('should pass `wrapNumbers` to entityFromEntityProto as boolean', () => { + testEntity.formatArray(results, true); + wrapNumbers = entityFromEntityProtoStub.getCall(0).args[1]; + assert.strictEqual(typeof wrapNumbers, 'boolean'); + }); + + it('should pass `wrapNumbers` to entityFromEntityProto as IntegerTypeCastOptions', () => { + const integerTypeCastOptions = { + integerTypeCastFunction: () => {}, + properties: 'that', + }; + + testEntity.formatArray(results, integerTypeCastOptions); + wrapNumbers = entityFromEntityProtoStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbers, integerTypeCastOptions); + assert.deepStrictEqual(wrapNumbers, integerTypeCastOptions); + }); + }); + }); + + describe('isKeyComplete', () => { + it('should convert key to key proto', done => { + const key = new testEntity.Key({ + path: ['Kind', 123], + }); + + testEntity.keyToKeyProto = (key_: {}) => { + assert.strictEqual(key_, key); + setImmediate(done); + return key; + }; + + testEntity.isKeyComplete(key); + }); + + it('should return true if key has id', () => { + const key = new testEntity.Key({ + path: ['Kind', 123], + }); + + assert.strictEqual(testEntity.isKeyComplete(key), true); + }); + + it('should return true if key has name', () => { + const key = new testEntity.Key({ + path: ['Kind', 'name'], + }); + + assert.strictEqual(testEntity.isKeyComplete(key), true); + }); + + it('should return false if key does not have name or ID', () => { + const key = new testEntity.Key({ + path: ['Kind'], + }); + + assert.strictEqual(testEntity.isKeyComplete(key), false); + }); + }); + + describe('keyFromKeyProto', () => { + const NAMESPACE = 'Namespace'; + + const keyProto = { + partitionId: { + namespaceId: NAMESPACE, + projectId: 'project-id', + }, + path: [ + { + idType: 'id', + kind: 'Kind', + id: '111', + }, + { + idType: 'name', + kind: 'Kind2', + name: 'name', + }, + ], + }; + + it('should set the namespace', done => { + testEntity.Key = class { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(keyOptions: any) { + assert.strictEqual(keyOptions.namespace, NAMESPACE); + done(); + } + }; + testEntity.keyFromKeyProto(keyProto); + }); + + it('should create a proper Key', done => { + testEntity.Key = class { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(keyOptions: any) { + assert.deepStrictEqual(keyOptions, { + namespace: NAMESPACE, + path: ['Kind', new testEntity.Int(111), 'Kind2', 'name'], + }); + done(); + } + }; + testEntity.keyFromKeyProto(keyProto); + }); + + it('should return the created Key', () => { + const expectedValue = {}; + + testEntity.Key = class { + constructor() { + return expectedValue; + } + }; + + assert.strictEqual(testEntity.keyFromKeyProto(keyProto), expectedValue); + }); + + it('should throw if path is invalid', done => { + const keyProtoInvalid = { + partitionId: { + namespaceId: 'Namespace', + projectId: 'project-id', + }, + path: [ + { + kind: 'Kind', + }, + { + kind: 'Kind2', + }, + ], + }; + + try { + testEntity.keyFromKeyProto(keyProtoInvalid); + } catch (e) { + assert.strictEqual((e as Error).name, 'InvalidKey'); + assert.strictEqual( + (e as Error).message, + 'Ancestor keys require an id or name.', + ); + done(); + } + }); + }); + + describe('keyToKeyProto', () => { + it('should handle hierarchical key definitions', () => { + const key = new testEntity.Key({ + path: ['Kind1', 1, 'Kind2', 'name', 'Kind3', new testEntity.Int(3)], + }); + + const keyProto = testEntity.keyToKeyProto(key); + + assert.strictEqual(keyProto.partitionId, undefined); + + assert.strictEqual(keyProto.path[0].kind, 'Kind1'); + assert.strictEqual(keyProto.path[0].id, 1); + assert.strictEqual(keyProto.path[0].name, undefined); + + assert.strictEqual(keyProto.path[1].kind, 'Kind2'); + assert.strictEqual(keyProto.path[1].id, undefined); + assert.strictEqual(keyProto.path[1].name, 'name'); + + assert.strictEqual(keyProto.path[2].kind, 'Kind3'); + assert.strictEqual(keyProto.path[2].id, new testEntity.Int(3).value); + assert.strictEqual(keyProto.path[2].name, undefined); + }); + + it('should detect the namespace of the hierarchical keys', () => { + const key = new testEntity.Key({ + namespace: 'Namespace', + path: ['Kind1', 1, 'Kind2', 'name'], + }); + + const keyProto = testEntity.keyToKeyProto(key); + + assert.strictEqual(keyProto.partitionId.namespaceId, 'Namespace'); + + assert.strictEqual(keyProto.path[0].kind, 'Kind1'); + assert.strictEqual(keyProto.path[0].id, 1); + assert.strictEqual(keyProto.path[0].name, undefined); + + assert.strictEqual(keyProto.path[1].kind, 'Kind2'); + assert.strictEqual(keyProto.path[1].id, undefined); + assert.strictEqual(keyProto.path[1].name, 'name'); + }); + + it('should handle incomplete keys with & without namespaces', () => { + const incompleteKey = new testEntity.Key({ + path: ['Kind'], + }); + + const incompleteKeyWithNs = new testEntity.Key({ + namespace: 'Namespace', + path: ['Kind'], + }); + + const keyProto = testEntity.keyToKeyProto(incompleteKey); + const keyProtoWithNs = testEntity.keyToKeyProto(incompleteKeyWithNs); + + assert.strictEqual(keyProto.partitionId, undefined); + assert.strictEqual(keyProto.path[0].kind, 'Kind'); + assert.strictEqual(keyProto.path[0].id, undefined); + assert.strictEqual(keyProto.path[0].name, undefined); + + assert.strictEqual(keyProtoWithNs.partitionId.namespaceId, 'Namespace'); + assert.strictEqual(keyProtoWithNs.path[0].kind, 'Kind'); + assert.strictEqual(keyProtoWithNs.path[0].id, undefined); + assert.strictEqual(keyProtoWithNs.path[0].name, undefined); + }); + + it('should throw if key contains 0 items', done => { + const key = new testEntity.Key({ + path: [], + }); + + try { + testEntity.keyToKeyProto(key); + } catch (e) { + assert.strictEqual((e as Error).name, 'InvalidKey'); + assert.strictEqual( + (e as Error).message, + 'A key should contain at least a kind.', + ); + done(); + } + }); + + it('should throw if key path contains null ids', done => { + const key = new testEntity.Key({ + namespace: 'Namespace', + path: ['Kind1', null, 'Company'], + }); + + try { + testEntity.keyToKeyProto(key); + } catch (e) { + assert.strictEqual((e as Error).name, 'InvalidKey'); + assert.strictEqual( + (e as Error).message, + 'Ancestor keys require an id or name.', + ); + done(); + } + }); + + it('should not throw if key is incomplete', () => { + const key = new testEntity.Key({ + namespace: 'Namespace', + path: ['Kind1', 123, 'Company', null], + }); + + assert.doesNotThrow(() => { + testEntity.keyToKeyProto(key); + }); + }); + }); + + describe('queryToQueryProto', () => { + const queryProto = { + distinctOn: [ + { + name: 'name', + }, + ], + kind: [ + { + name: 'Kind1', + }, + ], + order: [ + { + property: { + name: 'name', + }, + direction: 'ASCENDING', + }, + ], + projection: [ + { + property: { + name: 'name', + }, + }, + ], + endCursor: 'end', + limit: { + value: 1, + }, + offset: 1, + startCursor: 'start', + filter: { + compositeFilter: { + filters: [ + { + propertyFilter: { + property: { + name: 'name', + }, + op: 'EQUAL', + value: { + stringValue: 'John', + }, + }, + }, + { + propertyFilter: { + property: { + name: '__key__', + }, + op: 'HAS_ANCESTOR', + value: { + keyValue: { + path: [ + { + kind: 'Kind2', + name: 'somename', + }, + ], + }, + }, + }, + }, + ], + op: 'AND', + }, + }, + }; + + it('should support all configurations of a query', () => { + const ancestorKey = new entity.Key({ + path: ['Kind2', 'somename'], + }); + + const ds = new Datastore({projectId: 'project-id'}); + + const query = ds + .createQuery('Kind1') + .filter(new PropertyFilter('name', '=', 'John')) + .start('start') + .end('end') + .groupBy(['name']) + .order('name') + .select('name') + .limit(1) + .offset(1) + .hasAncestor(ancestorKey); + + assert.deepStrictEqual(testEntity.queryToQueryProto(query), queryProto); + }); + + it('should support using __key__ with array as value', () => { + const keyWithInQuery = { + distinctOn: [], + filter: { + compositeFilter: { + filters: [ + { + propertyFilter: { + op: 'IN', + property: { + name: '__key__', + }, + value: { + arrayValue: { + values: [ + { + keyValue: { + path: [ + { + kind: 'Kind1', + name: 'key1', + }, + ], + }, + }, + ], + }, + }, + }, + }, + ], + op: 'AND', + }, + }, + kind: [ + { + name: 'Kind1', + }, + ], + order: [], + projection: [], + }; + + const ds = new Datastore({projectId: 'project-id'}); + + const query = ds + .createQuery('Kind1') + .filter( + new PropertyFilter('__key__', 'IN', [ + new entity.Key({path: ['Kind1', 'key1']}), + ]), + ); + + assert.deepStrictEqual( + testEntity.queryToQueryProto(query), + keyWithInQuery, + ); + }); + + it('should support the filter method with Filter objects', () => { + const ancestorKey = new entity.Key({ + path: ['Kind2', 'somename'], + }); + + const ds = new Datastore({projectId: 'project-id'}); + + const query = ds + .createQuery('Kind1') + .filter(new PropertyFilter('name', '=', 'John')) + .start('start') + .end('end') + .groupBy(['name']) + .order('name') + .select('name') + .limit(1) + .offset(1) + .hasAncestor(ancestorKey); + assert.deepStrictEqual(testEntity.queryToQueryProto(query), queryProto); + }); + + it('should support the filter method with AND', () => { + const ancestorKey = new entity.Key({ + path: ['Kind2', 'somename'], + }); + + const ds = new Datastore({projectId: 'project-id'}); + + const query = ds + .createQuery('Kind1') + .filter( + and([ + new PropertyFilter('name', '=', 'John'), + new PropertyFilter('__key__', 'HAS_ANCESTOR', ancestorKey), + ]), + ) + .start('start') + .end('end') + .groupBy(['name']) + .order('name') + .select('name') + .limit(1) + .offset(1); + const testFilters = queryProto.filter; + const computedFilters = + testEntity.queryToQueryProto(query).filter.compositeFilter.filters[0]; + assert.deepStrictEqual(computedFilters, testFilters); + }); + + it('should handle buffer start and end values', () => { + const ds = new Datastore({projectId: 'project-id'}); + const startVal = Buffer.from('start'); + const endVal = Buffer.from('end'); + + const query = ds.createQuery('Kind1').start(startVal).end(endVal); + + const queryProto = testEntity.queryToQueryProto(query); + assert.strictEqual(queryProto.endCursor, endVal); + assert.strictEqual(queryProto.startCursor, startVal); + }); + }); + + describe('UrlSafeKey', () => { + const PROJECT_ID = 'grass-clump-479'; + const LOCATION_PREFIX = 's~'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let urlSafeKey: any; + + beforeEach(() => { + urlSafeKey = new testEntity.URLSafeKey(); + }); + + describe('convertToBase64_', () => { + it('should convert buffer to base64 and cleanup', () => { + const buffer = Buffer.from('Hello World'); + + assert.strictEqual( + urlSafeKey.convertToBase64_(buffer), + 'SGVsbG8gV29ybGQ', + ); + }); + }); + + describe('convertToBuffer_', () => { + it('should convert encoded url safe key to buffer', () => { + assert.deepStrictEqual( + urlSafeKey.convertToBuffer_('aGVsbG8gd29ybGQgZnJvbSBkYXRhc3RvcmU'), + Buffer.from('hello world from datastore'), + ); + }); + }); + + describe('legacyEncode', () => { + it('should encode with namespace', () => { + const kind = 'Task'; + const name = 'sampletask1'; + const key = new testEntity.Key({ + namespace: 'NS', + path: [kind, name], + }); + + const encodedKey = + 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIVCxIEVGFzayILc2FtcGxldGFzazEMogECTlM'; + assert.strictEqual( + urlSafeKey.legacyEncode(PROJECT_ID, key, LOCATION_PREFIX), + encodedKey, + ); + }); + + it('should encode key with single path element string string type', () => { + const kind = 'Task'; + const name = 'sampletask1'; + const key = new testEntity.Key({ + path: [kind, name], + }); + + const encodedKey = + 'ag9ncmFzcy1jbHVtcC00NzlyFQsSBFRhc2siC3NhbXBsZXRhc2sxDA'; + assert.strictEqual( + urlSafeKey.legacyEncode(PROJECT_ID, key), + encodedKey, + ); + }); + + it('should encode key with single path element long int type', () => { + const kind = 'Task'; + const id = 5754248394440704; + const key = new testEntity.Key({ + path: [kind, id], + }); + + const encodedKey = 'ag9ncmFzcy1jbHVtcC00NzlyEQsSBFRhc2sYgICA3NWunAoM'; + assert.strictEqual( + urlSafeKey.legacyEncode(PROJECT_ID, key), + encodedKey, + ); + }); + + it('should encode key with single path element entity int type', () => { + const kind = 'Task'; + const id = new testEntity.Int('5754248394440704'); + const key = new testEntity.Key({ + path: [kind, id], + }); + + const encodedKey = 'ag9ncmFzcy1jbHVtcC00NzlyEQsSBFRhc2sYgICA3NWunAoM'; + assert.strictEqual( + urlSafeKey.legacyEncode(PROJECT_ID, key), + encodedKey, + ); + }); + + it('should encode key with parent', () => { + const key = new testEntity.Key({ + path: ['Task', 'sampletask1', 'Task', 'sampletask2'], + }); + + const encodedKey = + 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIqCxIEVGFzayILc2FtcGxldGFzazEMCxIEVGFzayILc2FtcGxldGFzazIM'; + assert.strictEqual( + urlSafeKey.legacyEncode(PROJECT_ID, key, LOCATION_PREFIX), + encodedKey, + ); + }); + }); + + describe('legacyDecode', () => { + it('should decode key with namespace', () => { + const encodedKey = + 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIVCxIEVGFzayILc2FtcGxldGFzazEMogECTlM'; + const key = urlSafeKey.legacyDecode(encodedKey); + assert.strictEqual(key.namespace, 'NS'); + assert.deepStrictEqual(key.path, ['Task', 'sampletask1']); + }); + + it('should decode key with single path element string type', () => { + const encodedKey = + 'ag9ncmFzcy1jbHVtcC00NzlyFQsSBFRhc2siC3NhbXBsZXRhc2sxDA'; + const key = urlSafeKey.legacyDecode(encodedKey); + assert.strictEqual(key.namespace, undefined); + assert.deepStrictEqual(key.path, ['Task', 'sampletask1']); + }); + + it('should decode key with single path element long int type', () => { + const encodedKey = + 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIRCxIEVGFzaxiAgIDc1a6cCgw'; + const key = urlSafeKey.legacyDecode(encodedKey); + assert.strictEqual(key.namespace, undefined); + assert.deepStrictEqual(key.path, ['Task', '5754248394440704']); + }); + + it('should decode key with parent path', () => { + const encodedKey = + 'ahFzfmdyYXNzLWNsdW1wLTQ3OXIqCxIEVGFzayILc2FtcGxldGFzazEMCxIEVGFzayILc2FtcGxldGFzazIM'; + const key = urlSafeKey.legacyDecode(encodedKey); + assert.strictEqual(key.namespace, undefined); + assert.deepStrictEqual(key.path, [ + 'Task', + 'sampletask1', + 'Task', + 'sampletask2', + ]); + assert.strictEqual(key.parent!.name, 'sampletask1'); + assert.deepStrictEqual(key.parent!.path, ['Task', 'sampletask1']); + }); + }); + }); +}); diff --git a/handwritten/nodejs-datastore/test/entity/buildEntityProto.ts b/handwritten/nodejs-datastore/test/entity/buildEntityProto.ts new file mode 100644 index 00000000000..2d2c868df98 --- /dev/null +++ b/handwritten/nodejs-datastore/test/entity/buildEntityProto.ts @@ -0,0 +1,89 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {describe} from 'mocha'; +import {Entities, EntityObject, EntityProto} from '../../src/entity'; +import * as assert from 'assert'; +import {buildEntityProto} from '../../src/utils/entity/buildEntityProto'; +import { + entityObject, + expectedEntityProto, +} from '../fixtures/entityObjectAndProto'; + +const async = require('async'); + +describe('buildEntityProto', () => { + async.each( + [ + { + name: 'should format an entity', + entityObject: { + data: { + name: 'Stephen', + }, + }, + expectedProto: { + key: null, + properties: { + name: { + stringValue: 'Stephen', + }, + }, + }, + skipped: false, + }, + { + name: 'should format an entity array', + entityObject: { + data: [ + { + name: 'Stephen', + value: 'Stephen value', + }, + ], + }, + expectedProto: { + properties: { + Stephen: { + stringValue: 'Stephen value', + }, + }, + }, + skipped: false, + }, + { + name: 'should respect excludeFromIndexes', + skipped: false, + entityObject: entityObject, + expectedProto: expectedEntityProto, + }, + ], + (test: { + name: string; + skipped: boolean; + entityObject: EntityObject; + expectedProto: EntityProto; + }) => { + it(test.name, function () { + if (test.skipped) { + this.skip(); + } + assert.deepStrictEqual( + buildEntityProto(test.entityObject), + test.expectedProto, + ); + }); + }, + ); +}); diff --git a/handwritten/nodejs-datastore/test/entity/excludeIndexesAndBuildProto.ts b/handwritten/nodejs-datastore/test/entity/excludeIndexesAndBuildProto.ts new file mode 100644 index 00000000000..56ce082316c --- /dev/null +++ b/handwritten/nodejs-datastore/test/entity/excludeIndexesAndBuildProto.ts @@ -0,0 +1,380 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {describe} from 'mocha'; +import {Entities, EntityObject} from '../../src/entity'; +import {extendExcludeFromIndexes} from '../../src/utils/entity/extendExcludeFromIndexes'; +import {buildEntityProto} from '../../src/utils/entity/buildEntityProto'; +import * as is from 'is'; +import * as assert from 'assert'; +import {ServiceError} from 'google-gax'; +import {entityObject} from '../fixtures/entityObjectAndProto'; +import {complexCaseEntities} from '../fixtures/complexCaseLargeStrings'; +const async = require('async'); + +describe('excludeIndexesAndBuildProto', () => { + const longString = Buffer.alloc(1501, '.').toString(); + + /** + * This recursive function ensures that in the entityProtoSubset there is only + * an excludeFromIndexes: true value next to large values in the + * entityProtoSubset and throws an assertion error if there is not. + * + * @param {any} entityProtoSubset The entityProtoSubset to search. + * @param {string} path The path to the entityProtoSubset being searched. + */ + function checkEntityProto(entityProtoSubset: any, path: string) { + if (Array.isArray(entityProtoSubset)) { + entityProtoSubset.forEach((subset, index) => { + checkEntityProto(subset, `${path}.[${index}]`); + }); + } else { + if (is.object(entityProtoSubset)) { + if (entityProtoSubset.stringValue === longString) { + if (entityProtoSubset.excludeFromIndexes !== true) { + assert.fail( + `The entity proto at ${path} should excludeFromIndexes`, + ); + } + } else { + if (entityProtoSubset.excludeFromIndexes === true) { + assert.fail( + `The entity proto at ${path} should not excludeFromIndexes`, + ); + } + } + Object.keys(entityProtoSubset).map(property => { + checkEntityProto(entityProtoSubset[property], `${path}.${property}`); + }); + } + } + } + + /** + * This describe block makes sure that the recursive checkEntityProto + * function works as intended. It ensures that checkEntityProto throws an + * error for `excludeFromIndexes: true` entries that are missing or out of + * place and it also ensures checkEntityProto doesn't throw an error when + * proper entity protos are provided. + * + */ + describe('checkEntityProto', () => { + it('should not throw an assertion error on a simple check', () => { + checkEntityProto( + { + properties: { + name: { + stringValue: 'entityName', + }, + value: { + stringValue: 'entityValue', + }, + }, + }, + '', + ); + }); + it('should not throw an assertion error for long strings in the top level', () => { + checkEntityProto( + { + properties: { + name: { + stringValue: longString, + excludeFromIndexes: true, + }, + value: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + }, + '', + ); + }); + it('should throw an assertion error for a missing excludeFromIndexes: true', () => { + try { + checkEntityProto( + { + properties: { + name: { + stringValue: longString, + }, + value: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + }, + '', + ); + assert.fail('checkEntityProto should have failed'); + } catch (e) { + assert.strictEqual( + (e as ServiceError).message, + 'The entity proto at .properties.name should excludeFromIndexes', + ); + } + }); + it('should throw an assertion error for an extra excludeFromIndexes: true', () => { + try { + checkEntityProto( + { + properties: { + name: { + stringValue: 'not a long string', + excludeFromIndexes: true, + }, + value: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + }, + '', + ); + assert.fail('checkEntityProto should have failed'); + } catch (e) { + assert.strictEqual( + (e as ServiceError).message, + 'The entity proto at .properties.name should not excludeFromIndexes', + ); + } + }); + it('should throw an assertion error for an extra excludeFromIndexes: true', () => { + try { + checkEntityProto( + { + properties: { + name: { + arrayValue: { + values: [ + { + stringValue: longString, + excludeFromIndexes: true, + }, + { + entityValue: { + properties: { + metadata: { + excludeFromIndexes: true, + }, + }, + }, + }, + ], + }, + }, + value: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + }, + '', + ); + assert.fail('checkEntityProto should have failed'); + } catch (e) { + assert.strictEqual( + (e as ServiceError).message, + 'The entity proto at .properties.name.arrayValue.values.[1].entityValue.properties.metadata should not excludeFromIndexes', + ); + } + }); + }); + + /** + * These are the basic test cases each with an entity object that will be + * tested. The entity object in each test case will be encoded into an entity + * proto and then the entity proto will be checked to ensure + * excludeFromIndexes: true is in the proper places. + */ + const testCases: {name: string; entities: Entities; skipped: boolean}[] = [ + { + name: 'Should encode a simple object properly', + skipped: false, + entities: { + name: 'firstElementName', + value: longString, + }, + }, + { + name: 'Should encode a complex set of entities without large values', + skipped: false, + entities: entityObject.data, + }, + { + name: 'Should encode a complex set of entities with large values', + skipped: false, + entities: complexCaseEntities, + }, + { + name: 'Should encode a long string in a nested field', + skipped: false, + entities: [ + { + name: 'field_b', + value: { + nestedField: Buffer.alloc(1501, '.').toString(), + }, + }, + ], + }, + { + name: 'Should exclude large properties in a nested array', + skipped: false, + entities: { + metadata: [ + { + name: longString, + value: 'some-value', + }, + ], + }, + }, + ]; + + interface GeneratedTestCase { + entities: any; + name: string; + isArray: boolean; + } + + /** + * This function generates a wide variety of Entity Object structures so that + * in our tests we can ensure each one of them gets encoded into an entity + * proto with `excludeFromIndexes: true` in exactly all the right places. + * + * @param {object} baseElement The element that will appear at all leaf nodes + * of the entity proto. + * @param {string} baseTestName The name of the test that the generated + * components will correspond to. + */ + function getGeneratedTestComponents( + baseElement: {}, + baseTestName: string, + ): GeneratedTestCase[] { + const maxDepth = 5; + const generatedTestCasesByDepth: GeneratedTestCase[][] = [ + [{entities: baseElement, name: baseTestName, isArray: false}], + ]; + for (let depth = 1; depth < maxDepth; depth++) { + const newElements: GeneratedTestCase[] = []; + generatedTestCasesByDepth[depth - 1].forEach(element => { + const entities = element.entities; + if (!element.isArray) { + /** + * Note that if the proto contains an array of an array then the + * server will return the following error: + * Error: 3 INVALID_ARGUMENT: list_value cannot contain a Value containing another list_value. + * + * Therefore, arrays of arrays are not supported so this if statement + * is here so that we don't generate tests for those cases. + */ + newElements.push({ + entities: [entities, entities], + name: element.name + '.[]', + isArray: true, + }); + } + newElements.push({ + entities: { + name: entities, + value: entities, + otherProperty: entities, + }, + name: element.name + '.{}', + isArray: false, + }); + }); + generatedTestCasesByDepth.push(newElements); + } + return generatedTestCasesByDepth[maxDepth - 1]; + } + + /** + * This script adds a bunch of generated test cases with generated entity + * objects that will be converted into entity protos and checked for + * correctness. + * + */ + [ + getGeneratedTestComponents( + { + name: longString, + value: longString, + otherProperty: longString, + }, + 'with long string properties and path ', + ), + getGeneratedTestComponents( + { + name: longString, + value: 'short value', + otherProperty: longString, + }, + 'with long name property and path ', + ), + ] + .flat() + .forEach(component => { + testCases.push({ + skipped: false, + name: `Should encode a generated object ${component.name}`, + entities: { + name: component.entities, + value: component.entities, + otherProperty: component.entities, + }, + }); + testCases.push({ + skipped: false, + name: `Should encode a generated array ${component.name}`, + entities: [ + { + name: 'some-name', + value: component.entities, + }, + { + name: 'some-name', + value: component.entities, + }, + ], + }); + }); + + async.each( + testCases, + (test: {name: string; entities: Entities; skipped: boolean}) => { + it(test.name, function () { + /** + * This test ensures that excludeFromIndexes: true only appears in the + * entity proto in every place that corresponds to a large value. It + * does this using the checkEntityProto function which does a + * recursive check on the proto. + */ + if (test.skipped) { + this.skip(); + } + const entityObject = { + data: test.entities, + excludeLargeProperties: true, + excludeFromIndexes: [], + }; + extendExcludeFromIndexes(entityObject); + const entityProto = buildEntityProto(entityObject); + checkEntityProto(entityProto, ''); + }); + }, + ); +}); diff --git a/handwritten/nodejs-datastore/test/entity/extendExcludeFromIndexes.ts b/handwritten/nodejs-datastore/test/entity/extendExcludeFromIndexes.ts new file mode 100644 index 00000000000..936dbaa4854 --- /dev/null +++ b/handwritten/nodejs-datastore/test/entity/extendExcludeFromIndexes.ts @@ -0,0 +1,173 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {describe} from 'mocha'; +import {Entities} from '../../src/entity'; +import * as assert from 'assert'; +import {extendExcludeFromIndexes} from '../../src/utils/entity/extendExcludeFromIndexes'; + +const async = require('async'); + +describe('extendExcludeFromIndexes', () => { + const longString = Buffer.alloc(1501, '.').toString(); + // complexCaseEntities are passed into save for the complex case. + const complexCaseEntities = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + async.each( + [ + { + name: 'For a simple case involving a name/value pair', + entities: { + name: 'firstElementName', + value: longString, + }, + skipped: false, + expectedOutput: ['value'], + }, + { + name: 'For a simple case involving a name/value pair in an array', + entities: [ + { + name: 'firstElementName', + value: longString, + }, + ], + skipped: false, + expectedOutput: ['firstElementName'], + }, + { + name: 'For a complex case involving lots of entities', + entities: complexCaseEntities, + skipped: false, + expectedOutput: [ + 'longString', + 'longStringArray[]', + 'metadata.longString', + 'metadata.obj.longStringArray[].longString', + 'metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'metadata.longStringArray[].longString', + 'metadata.longStringArray[].nestedLongStringArray[].longString', + ], + }, + { + name: 'For a complex case involving a name/value pair', + entities: { + name: 'firstElementName', + value: complexCaseEntities, + }, + skipped: false, + expectedOutput: [ + 'value.longString', + 'value.longStringArray[]', + 'value.metadata.longString', + 'value.metadata.obj.longStringArray[].longString', + 'value.metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'value.metadata.longStringArray[].longString', + 'value.metadata.longStringArray[].nestedLongStringArray[].longString', + ], + }, + { + name: 'For a complex case involving and array and name/value', + entities: [ + { + name: 'firstElementName', + value: complexCaseEntities, + }, + ], + skipped: false, + expectedOutput: [ + 'firstElementName.longString', + 'firstElementName.longStringArray[]', + 'firstElementName.metadata.longString', + 'firstElementName.metadata.obj.longStringArray[].longString', + 'firstElementName.metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'firstElementName.metadata.longStringArray[].longString', + 'firstElementName.metadata.longStringArray[].nestedLongStringArray[].longString', + ], + }, + { + name: 'For some nested properties that happen to be called value and name', + entities: { + metadata: [ + { + name: longString, + value: 'some-value', + }, + ], + }, + skipped: false, + expectedOutput: ['metadata[].name'], + }, + ], + (test: { + name: string; + entities: Entities; + expectedOutput: string[]; + skipped: boolean; + }) => { + it(test.name, function () { + if (test.skipped) { + this.skip(); + } + const entityObject = { + data: test.entities, + excludeLargeProperties: true, + excludeFromIndexes: [], + }; + extendExcludeFromIndexes(entityObject); + assert.deepStrictEqual( + entityObject.excludeFromIndexes, + test.expectedOutput, + ); + }); + }, + ); +}); diff --git a/handwritten/nodejs-datastore/test/entity/findLargeProperties_.ts b/handwritten/nodejs-datastore/test/entity/findLargeProperties_.ts new file mode 100644 index 00000000000..028955baf64 --- /dev/null +++ b/handwritten/nodejs-datastore/test/entity/findLargeProperties_.ts @@ -0,0 +1,165 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as assert from 'assert'; +import {describe} from 'mocha'; +import {Entities, entity} from '../../src/entity'; +import findLargeProperties_ = entity.findLargeProperties_; + +const async = require('async'); + +describe('findLargeProperties_', () => { + const longString = Buffer.alloc(1501, '.').toString(); + // complexCaseEntities are passed into save for the complex case. + const complexCaseEntities = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + async.each( + [ + { + name: 'For a simple case involving a name/value pair', + entities: { + name: 'firstElementName', + value: longString, + }, + skipped: false, + expectedOutput: ['value'], + }, + { + name: 'For a simple case involving a name/value pair in an array', + entities: [ + { + name: 'firstElementName', + value: longString, + }, + ], + skipped: false, + expectedOutput: ['[].value'], + }, + { + name: 'For a complex case involving lots of entities', + entities: complexCaseEntities, + skipped: false, + expectedOutput: [ + 'longString', + 'longStringArray[]', + 'metadata.longString', + 'metadata.obj.longStringArray[].longString', + 'metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'metadata.longStringArray[].longString', + 'metadata.longStringArray[].nestedLongStringArray[].longString', + ], + }, + { + name: 'For a complex case involving a name/value pair', + entities: { + name: 'firstElementName', + value: complexCaseEntities, + }, + skipped: false, + expectedOutput: [ + 'value.longString', + 'value.longStringArray[]', + 'value.metadata.longString', + 'value.metadata.obj.longStringArray[].longString', + 'value.metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'value.metadata.longStringArray[].longString', + 'value.metadata.longStringArray[].nestedLongStringArray[].longString', + ], + }, + { + name: 'For a complex case involving and array and name/value', + entities: [ + { + name: 'firstElementName', + value: complexCaseEntities, + }, + ], + skipped: false, + expectedOutput: [ + '[].value.longString', + '[].value.longStringArray[]', + '[].value.metadata.longString', + '[].value.metadata.obj.longStringArray[].longString', + '[].value.metadata.obj.longStringArray[].nestedLongStringArray[].longString', + '[].value.metadata.longStringArray[].longString', + '[].value.metadata.longStringArray[].nestedLongStringArray[].longString', + ], + }, + { + name: 'For some nested properties that happen to be called value and name', + entities: { + metadata: [ + { + name: longString, + value: 'some-value', + }, + ], + }, + skipped: false, + expectedOutput: ['metadata[].name'], + }, + ], + (test: { + name: string; + entities: Entities; + expectedOutput: string[]; + skipped: boolean; + }) => { + it(test.name, function () { + if (test.skipped) { + this.skip(); + } + const output = findLargeProperties_(test.entities, '', []); + assert.deepStrictEqual(output, test.expectedOutput); + }); + }, + ); +}); diff --git a/handwritten/nodejs-datastore/test/fixtures/complexCaseLargeStrings.ts b/handwritten/nodejs-datastore/test/fixtures/complexCaseLargeStrings.ts new file mode 100644 index 00000000000..82e32515083 --- /dev/null +++ b/handwritten/nodejs-datastore/test/fixtures/complexCaseLargeStrings.ts @@ -0,0 +1,55 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +// complexCaseEntities are passed into save for the complex case. +const longString = Buffer.alloc(1501, '.').toString(); +export const complexCaseEntities = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, +}; diff --git a/handwritten/nodejs-datastore/test/fixtures/entityObjectAndProto.ts b/handwritten/nodejs-datastore/test/fixtures/entityObjectAndProto.ts new file mode 100644 index 00000000000..d23eddd4abd --- /dev/null +++ b/handwritten/nodejs-datastore/test/fixtures/entityObjectAndProto.ts @@ -0,0 +1,435 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +const value1 = 'Stephen'; +const value2 = 'Stephen2'; +const value3 = 'Stephen3'; +const value4 = 'Stephen4'; +const value5 = 'Stephen5'; +const value6 = 'Stephen6'; +const value7 = 'Stephen7'; +const value8 = 'Stephen8'; +const value9 = 'Stephen9'; +const value10 = 'Stephen10'; +const value11 = 'Stephen11'; +const value12 = 'Stephen12'; +const value13 = 'something'; +const value14 = 'else'; +const value15 = 'whatever'; + +const entityObject = { + excludeFromIndexes: [ + 'name', + 'entity.name', + 'array[]', + 'array[].name', + 'array[].entity.name', + 'array[].entity.array[].name', + 'array[].array[].entity.name', + 'entityExcluded[].name', + 'primitiveExcluded[]', + 'rules[].requirements[].audiences', + 'nestedArrayVariants[].a[].b', + 'alpha[]', + 'omega', + ], + + data: { + name: value1, + + entity: { + name: value2, + }, + + entityExcluded: [ + value3, + { + name: value4, + }, + ], + + primitiveExcluded: [ + value5, + { + name: value6, + }, + ], + + array: [ + value7, + { + name: value8, + }, + { + entity: { + name: value9, + array: [ + { + name: value10, + }, + ], + }, + }, + { + array: [ + { + entity: { + name: value11, + }, + }, + ], + }, + ], + + rules: [ + { + requirements: [ + { + audiences: value12, + }, + ], + }, + { + requirements: null, + }, + ], + + nestedArrayVariants: [ + { + a: [{b: value13}, {c: value14}], + }, + { + a: null, + }, + { + a: [value15], + }, + { + a: [{b: ['nasty', 'array']}], + }, + ], + + alpha: ['beta', 'gamma'], + + omega: ['beta', 'gamma'], + }, +}; + +const expectedEntityProto = { + key: null, + properties: { + name: { + stringValue: value1, + excludeFromIndexes: true, + }, + entity: { + entityValue: { + properties: { + name: { + stringValue: value2, + excludeFromIndexes: true, + }, + }, + }, + }, + entityExcluded: { + arrayValue: { + values: [ + { + stringValue: value3, + }, + { + entityValue: { + properties: { + name: { + stringValue: value4, + excludeFromIndexes: true, + }, + }, + }, + }, + ], + }, + }, + primitiveExcluded: { + arrayValue: { + values: [ + { + stringValue: value5, + excludeFromIndexes: true, + }, + { + entityValue: { + properties: { + name: { + stringValue: value6, + }, + }, + }, + excludeFromIndexes: true, + }, + ], + }, + }, + array: { + arrayValue: { + values: [ + { + stringValue: value7, + excludeFromIndexes: true, + }, + { + entityValue: { + properties: { + name: { + stringValue: value8, + excludeFromIndexes: true, + }, + }, + }, + excludeFromIndexes: true, + }, + { + entityValue: { + properties: { + entity: { + entityValue: { + properties: { + name: { + stringValue: value9, + excludeFromIndexes: true, + }, + array: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + name: { + stringValue: value10, + excludeFromIndexes: true, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + }, + }, + excludeFromIndexes: true, + }, + { + entityValue: { + properties: { + array: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + entity: { + entityValue: { + properties: { + name: { + stringValue: value11, + excludeFromIndexes: true, + }, + }, + }, + }, + }, + }, + }, + ], + }, + }, + }, + }, + excludeFromIndexes: true, + }, + ], + }, + }, + rules: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + requirements: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + audiences: { + stringValue: value12, + excludeFromIndexes: true, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + { + entityValue: { + properties: { + requirements: { + nullValue: 0, + }, + }, + }, + }, + ], + }, + }, + nestedArrayVariants: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + a: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + b: { + stringValue: value13, + excludeFromIndexes: true, + }, + }, + }, + }, + { + entityValue: { + properties: { + c: { + stringValue: value14, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + { + entityValue: { + properties: { + a: { + nullValue: 0, + }, + }, + }, + }, + { + entityValue: { + properties: { + a: { + arrayValue: { + values: [ + { + stringValue: value15, + }, + ], + }, + }, + }, + }, + }, + { + entityValue: { + properties: { + a: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + b: { + // excludeFromIndexes: + // ['nestedArrayVariants[].a[].b'] does not + // apply here, + // To exclude this array (= all its + // elements), we would use + // ['nestedArrayVariants[].a[].b[]'] + arrayValue: { + values: [ + { + stringValue: 'nasty', + }, + { + stringValue: 'array', + }, + ], + }, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + ], + }, + }, + alpha: { + // `excludeFromIndexes: ['alpha[]']` results in exclusion of all + // array elements + arrayValue: { + values: [ + { + excludeFromIndexes: true, + stringValue: 'beta', + }, + { + excludeFromIndexes: true, + stringValue: 'gamma', + }, + ], + }, + }, + omega: { + // `excludeFromIndexes: ['omega']` is not applied, because 'omega' + // is an array. + arrayValue: { + values: [ + { + stringValue: 'beta', + }, + { + stringValue: 'gamma', + }, + ], + }, + }, + }, +}; + +export {entityObject, expectedEntityProto}; diff --git a/handwritten/nodejs-datastore/test/gapic-mocks/client-initialization-testing.ts b/handwritten/nodejs-datastore/test/gapic-mocks/client-initialization-testing.ts new file mode 100644 index 00000000000..de5230ae3b1 --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic-mocks/client-initialization-testing.ts @@ -0,0 +1,165 @@ +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {beforeEach, describe, it} from 'mocha'; +import { + Datastore, + DatastoreClient, + Fallback, + DatastoreRequest, + DatastoreOptions, +} from '../../src'; +import * as assert from 'assert'; +import * as proxyquire from 'proxyquire'; +import {Callback, CallOptions} from 'google-gax'; +import * as protos from '../../protos/protos'; +import * as ds from '../../src'; +import * as mocha from 'mocha'; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type Any = any; + +const clientName = 'DatastoreClient'; +const async = require('async'); + +/** + * This class mocks out the lookup function so that for tests in this file + * the lookup function just sends data back instead of making a call to the + * server. The class also saves the rest parameter in the constructor so that + * it can be read later for correctness. + * + */ +class FakeDatastoreClient extends DatastoreClient { + restParameter: Fallback; + constructor(...args: any[]) { + super(); + this.restParameter = args[0].fallback; + } + lookup( + request?: protos.google.datastore.v1.ILookupRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | null | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | null | undefined, + {} | null | undefined + >, + ): Promise< + [ + protos.google.datastore.v1.ILookupResponse, + protos.google.datastore.v1.ILookupRequest | undefined, + {} | undefined, + ] + > { + if (callback) { + callback(null, {}); + } + return new Promise((resolve, reject) => { + resolve([{}, {}, {}]); + }); + } +} + +describe('Client Initialization Testing', () => { + describe('Request', () => { + let Request: typeof ds.DatastoreRequest; + let request: Any; + + /** + * This function is called by a test to ensure that the rest parameter + * gets passed to the Gapic data client's constructor + * + * @param {DatastoreRequest} [request] The request object whose data client + * the test makes comparisons with. + * @param {string | undefined} [expectedFallback] The value that the test + * expects the rest parameter of the data client to be equal to. + * @param {mocha.Done} [done] The done function used for indicating + * that the test is complete or that there is an error in the mocha test + * environment. + * + */ + function compareRequest( + request: DatastoreRequest, + expectedFallback: Fallback, + done: mocha.Done, + ) { + try { + const client = request.datastore.clients_.get(clientName); + assert(client); + assert.strictEqual(client.restParameter, expectedFallback); + done(); + } catch (err: unknown) { + done(err); + } + } + async.each( + [ + { + options: {fallback: 'rest' as Fallback}, + expectedFallback: 'rest', + description: 'when specifying rest as a fallback parameter', + }, + { + options: {}, + expectedFallback: undefined, + description: 'when specifying no fallback parameter', + }, + ], + (testParameters: { + options: DatastoreOptions; + expectedFallback: Fallback; + description: string; + }) => { + describe(testParameters.description, () => { + beforeEach(() => { + Request = proxyquire('../../src/request', { + './v1': { + DatastoreClient: FakeDatastoreClient, + }, + }).DatastoreRequest; + request = new Request(); + request.datastore = new Datastore(testParameters.options); + // The CI environment can't fetch project id so the function that + // fetches the project id needs to be mocked out. + request.datastore.auth.getProjectId = ( + callback: (err: any, projectId: string) => void, + ) => { + callback(null, 'some-project-id'); + }; + }); + it('should set the rest parameter in the data client when calling prepareGaxRequest_', done => { + // This request does lazy initialization of the gapic layer Datastore client. + request.prepareGaxRequest_( + {client: clientName, method: 'lookup'}, + () => { + compareRequest(request, testParameters.expectedFallback, done); + }, + ); + }); + it('should set the rest parameter in the data client when calling request_', done => { + // This request does lazy initialization of the gapic layer Datastore client. + request.request_({client: clientName, method: 'lookup'}, () => { + compareRequest(request, testParameters.expectedFallback, done); + }); + }); + }); + }, + ); + }); +}); diff --git a/handwritten/nodejs-datastore/test/gapic-mocks/commit.ts b/handwritten/nodejs-datastore/test/gapic-mocks/commit.ts new file mode 100644 index 00000000000..3ef17096be5 --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic-mocks/commit.ts @@ -0,0 +1,584 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as assert from 'assert'; +import {describe} from 'mocha'; +import * as protos from '../../protos/protos'; +import {getInitializedDatastoreClient} from './get-initialized-datastore-client'; +import type {CallOptions} from 'google-gax'; +import {Entities} from '../../src/entity'; +import {google} from '../../protos/protos'; +import IValue = google.datastore.v1.IValue; +import {complexCaseEntities} from '../fixtures/complexCaseLargeStrings'; + +const async = require('async'); + +describe('Commit', () => { + const longString = Buffer.alloc(1501, '.').toString(); + const clientName = 'DatastoreClient'; + const datastore = getInitializedDatastoreClient(); + + const key = { + path: [ + { + kind: 'Post', + name: 'post2', + }, + ], + partitionId: { + namespaceId: 'namespace', + }, + }; + + // complexCaseProperties are expected mutations passed to Gapic. + const complexCaseProperties: {[k: string]: IValue} = { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + notMetadata: { + booleanValue: true, + }, + longStringArray: { + arrayValue: { + values: [ + { + stringValue: longString, + excludeFromIndexes: true, + }, + ], + }, + }, + metadata: { + entityValue: { + properties: { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + otherProperty: { + stringValue: 'value', + }, + obj: { + entityValue: { + properties: { + longStringArray: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + nestedLongStringArray: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + nestedProperty: { + booleanValue: true, + }, + }, + }, + }, + { + entityValue: { + properties: { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + longStringArray: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + nestedLongStringArray: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + nestedProperty: { + booleanValue: true, + }, + }, + }, + }, + { + entityValue: { + properties: { + longString: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + }; + + describe('save should pass the right properties to the gapic layer', () => { + async.each( + [ + { + name: 'should pass the right properties for a simple name/value pair', + skipped: false, + entities: { + name: 'entityName', + value: 'entityValue', + }, + excludeFromIndexes: [], // Empty because excludeLargeProperties populates the list. + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + properties: { + name: { + stringValue: 'entityName', + }, + value: { + stringValue: 'entityValue', + }, + }, + key, + }, + }, + ], + }, + { + // This test checks to see that when the name/value is wrapped in an array it parses the input differently. + name: 'should pass the right properties for a simple name/value pair in an array', + skipped: false, + entities: [ + { + name: 'entityName', + value: 'entityValue', + }, + ], + excludeFromIndexes: [], // Empty because excludeLargeProperties populates the list. + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + properties: { + entityName: { + stringValue: 'entityValue', + }, + }, + key, + }, + }, + ], + }, + { + name: 'should pass the right properties for a name/value pair in an array with a long string', + skipped: false, + entities: [ + { + name: 'entityName', + value: longString, + }, + ], + excludeFromIndexes: [], // Empty because excludeLargeProperties populates the list. + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + properties: { + entityName: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + key, + }, + }, + ], + }, + { + name: 'should position excludeFromIndexes in the right place when provided at the top level', + skipped: false, + entities: [ + { + name: 'entityName', + value: 'entityValue', + excludeFromIndexes: true, + }, + ], + excludeFromIndexes: [], + expectedMutations: [ + { + upsert: { + properties: { + entityName: { + stringValue: 'entityValue', + excludeFromIndexes: true, + }, + }, + key, + }, + }, + ], + }, + { + name: 'should pass the right properties for a simple name/value pair in an array with excludeFromIndexes list', + skipped: false, + entities: [ + { + name: 'entityName', + value: 'entityValue', + }, + ], + excludeFromIndexes: ['entityName'], + expectedMutations: [ + { + upsert: { + properties: { + entityName: { + stringValue: 'entityValue', + excludeFromIndexes: true, + }, + }, + key, + }, + }, + ], + }, + { + // This test is from a modified version of https://github.com/googleapis/nodejs-datastore/blob/bf3dafd8267c447a52f7764505042a60b1a9fd28/test/index.ts#L1773 + name: 'should pass the right request with a bunch of large properties excluded', + skipped: false, + entities: complexCaseEntities, + excludeFromIndexes: [ + 'longString', + 'longStringArray[]', + 'metadata.longString', + 'metadata.obj.longStringArray[].longString', + 'metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'metadata.longStringArray[].longString', + 'metadata.longStringArray[].nestedLongStringArray[].longString', + ], + excludeLargeProperties: false, + expectedMutations: [ + { + upsert: { + properties: complexCaseProperties, + key, + }, + }, + ], + }, + { + // Just like 'should pass the right request with a bunch of large properties excluded', but excludeLargeProperties is true + name: 'should pass the right properties for an object with excludeLargeProperties', + skipped: false, + entities: complexCaseEntities, + excludeFromIndexes: [], // Empty because excludeLargeProperties populates the list. + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + properties: complexCaseProperties, + key, + }, + }, + ], + }, + { + // This test case reproduces https://github.com/googleapis/nodejs-datastore/issues/1242 + name: 'should pass the right request with a nested field', + skipped: false, + entities: [ + { + name: 'field_b', + value: { + nestedField: Buffer.alloc(1501, '.').toString(), + }, + excludeFromIndexes: true, + }, + ], + excludeFromIndexes: [], + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + properties: { + field_b: { + entityValue: { + properties: { + nestedField: { + stringValue: longString, + excludeFromIndexes: true, + }, + }, + }, + excludeFromIndexes: true, + }, + }, + key, + }, + }, + ], + }, + { + // "should pass the right request with a bunch of large properties excluded" test with entities wrapped in name/value + name: 'should pass the right request with a name/value pair and a bunch of large properties excluded', + skipped: false, + entities: { + name: 'entityName', + value: complexCaseEntities, + }, + excludeFromIndexes: [ + 'value.longString', + 'value.longStringArray[]', + 'value.metadata.longString', + 'value.metadata.obj.longStringArray[].longString', + 'value.metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'value.metadata.longStringArray[].longString', + 'value.metadata.longStringArray[].nestedLongStringArray[].longString', + ], + excludeLargeProperties: false, + expectedMutations: [ + { + upsert: { + properties: { + name: { + stringValue: 'entityName', + }, + value: { + entityValue: { + properties: complexCaseProperties, + }, + }, + }, + key, + }, + }, + ], + }, + { + // "should pass the right properties for an object with excludeLargeProperties" test with entities wrapped in name/value + name: 'should pass the right request with a name/value pair and excludeLargeProperties set to true', + skipped: false, + entities: { + name: 'entityName', + value: complexCaseEntities, + }, + excludeFromIndexes: [], + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + properties: { + name: { + stringValue: 'entityName', + }, + value: { + entityValue: { + properties: complexCaseProperties, + }, + }, + }, + key, + }, + }, + ], + }, + { + // Just like the previous test, but entities are wrapped in an array + name: 'should pass the right properties for an array with name/value pairs and excludeLargeProperties', + skipped: false, + entities: [ + { + name: 'entityName', + value: complexCaseEntities, + }, + ], + excludeFromIndexes: [], + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + properties: { + entityName: { + entityValue: { + properties: complexCaseProperties, + }, + }, + }, + key, + }, + }, + ], + }, + { + name: 'should set the right properties for a nested name/value pair', + skipped: false, + entities: { + metadata: [ + { + name: longString, + value: 'some-value', + }, + ], + }, + excludeFromIndexes: [], + excludeLargeProperties: true, + expectedMutations: [ + { + upsert: { + key, + properties: { + metadata: { + arrayValue: { + values: [ + { + entityValue: { + properties: { + name: { + stringValue: longString, + excludeFromIndexes: true, + }, + value: { + stringValue: 'some-value', + }, + }, + }, + }, + ], + }, + }, + }, + }, + }, + ], + }, + ], + (test: { + name: string; + skipped: boolean; + entities: Entities; + excludeFromIndexes: string[]; + excludeLargeProperties: boolean; + expectedMutations: google.datastore.v1.IMutation[]; + }) => { + it(test.name, async function () { + if (test.skipped) { + this.skip(); + } + /** + * Replaces long strings in an object with so that they can + * be used in an assert comparison as assert has a character limit on the + * data that it can accept + * + * @param {google.datastore.v1.IMutation[] | null} input The input object + * containing the long strings that should be replaced. + * @returns {google.datastore.v1.IMutation[]} The input object with the long + * strings replaced. + */ + function replaceLongStrings( + input?: google.datastore.v1.IMutation[] | null, + ) { + const stringifiedInput = JSON.stringify(input); + const replacedInput = stringifiedInput + .split(longString) + .join(''); + return JSON.parse(replacedInput) as google.datastore.v1.IMutation[]; + } + { + // This code block is indented so the reader knows the rest of the test doesn't depend its definitions. + /* + Sets up the gapic client so that when it receives mutations it ensures that + the mutations match the expectedMutations and throw an assertion error if + they don't. + */ + const dataClient = datastore.clients_.get(clientName); + if (dataClient) { + dataClient.commit = ( + request: protos.google.datastore.v1.ICommitRequest, + options: CallOptions, + callback: ( + err?: unknown, + res?: protos.google.datastore.v1.ICommitResponse, + ) => void, + ) => { + try { + const actual = replaceLongStrings(request.mutations); + const expected = replaceLongStrings(test.expectedMutations); + assert.deepStrictEqual(actual, expected); + } catch (e) { + callback(e); + } + callback(null, { + mutationResults: [], + }); + }; + } + } + // Calls save and ensures that the right mutations are passed to the Gapic layer. + const postKey = datastore.key(['Post', 'post2']); + await datastore.save({ + key: postKey, + data: test.entities, + excludeFromIndexes: test.excludeFromIndexes, + excludeLargeProperties: test.excludeLargeProperties, + }); + }); + }, + ); + }); +}); diff --git a/handwritten/nodejs-datastore/test/gapic-mocks/error-mocks.ts b/handwritten/nodejs-datastore/test/gapic-mocks/error-mocks.ts new file mode 100644 index 00000000000..507c795ee9f --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic-mocks/error-mocks.ts @@ -0,0 +1,73 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as mocha from 'mocha'; +import * as assert from 'assert'; +import {Datastore} from '../../src'; + +/** + * Returns a callback function that expects an error with a particular + * message. This is used for testing all client library functions that accept + * a callback in order to ensure the callback receives a particular error. + * + * @param {mocha.Done} done The mocha done function which is called when the + * test finishes. + * @param {string} message The expected error message in the test. + * + */ +export function getCallbackExpectingError(done: mocha.Done, message: string) { + return (error?: Error | null) => { + try { + if (error) { + assert.strictEqual(error.message, message); + done(); + return; + } + done(new Error('The callback should have received an error')); + } catch (err: unknown) { + done(err); + } + }; +} + +/** + * This function ends the test with an error if a call reaches the gapic + * layer. Using this function in a test makes the test fail if any outgoing + * grpc calls are made in that test. This allows the test to ensure that no + * grpc calls happen, which is typically desired behaviour when an error is + * sent back to the user from the handwritten layer. + * + * @param {Datastore} datastore The datastore client. + * @param {string} clientName The datastore client. + * @param {mocha.Done} done The mocha done function which is called when the + * test finishes. + */ +export function errorOnGapicCall( + datastore: Datastore, + clientName: string, + done: mocha.Done, +) { + const dataClient = datastore.clients_.get(clientName); + if (dataClient) { + dataClient.runQuery = () => { + done(new Error('The gapic layer should not have received a call')); + }; + dataClient.runAggregationQuery = () => { + done(new Error('The gapic layer should not have received a call')); + }; + dataClient.lookup = () => { + done(new Error('The gapic layer should not have received a call')); + }; + } +} diff --git a/handwritten/nodejs-datastore/test/gapic-mocks/get-initialized-datastore-client.ts b/handwritten/nodejs-datastore/test/gapic-mocks/get-initialized-datastore-client.ts new file mode 100644 index 00000000000..bf3e4b652ed --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic-mocks/get-initialized-datastore-client.ts @@ -0,0 +1,44 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {Datastore} from '../../src'; + +/** + * This function gets a datastore client that has already been initialized + * meaning that its gapic data client has been created and is ready to be mocked + * out with whatever behavior is needed in a test. Mocking out the gapic client + * is common for testing handwritten layer behaviour because it is a way to + * evaluate data that reaches the handwritten layer thereby testing the + * handwritten layer in isolation. + */ +export function getInitializedDatastoreClient(): Datastore { + const clientName = 'DatastoreClient'; + const PROJECT_ID = 'project-id'; + const NAMESPACE = 'namespace'; + const options = { + projectId: PROJECT_ID, + namespace: NAMESPACE, + }; + const datastore = new Datastore(options); + // By default, datastore.clients_ is an empty map. + // To mock out commit we need the map to contain the Gapic data client. + // Normally a call to the data client through the datastore object would initialize it. + // We don't want to make this call because it would make a grpc request. + // So we just add the data client to the map. + const gapic = Object.freeze({ + v1: require('../../src/v1'), + }); + datastore.clients_.set(clientName, new gapic.v1[clientName](options)); + return datastore; +} diff --git a/handwritten/nodejs-datastore/test/gapic-mocks/handwritten-errors.ts b/handwritten/nodejs-datastore/test/gapic-mocks/handwritten-errors.ts new file mode 100644 index 00000000000..bba7952e2eb --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic-mocks/handwritten-errors.ts @@ -0,0 +1,117 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {describe} from 'mocha'; +import {AggregateField} from '../../src'; +import {getInitializedDatastoreClient} from './get-initialized-datastore-client'; +import {RunQueryOptions} from '../../src/query'; +import {errorOnGapicCall, getCallbackExpectingError} from './error-mocks'; +import * as assert from 'assert'; +const async = require('async'); + +describe('HandwrittenLayerErrors', () => { + describe('Can only specify one of transaction, consistency, readTime', () => { + const clientName = 'DatastoreClient'; + const datastore = getInitializedDatastoreClient(); + async.each( + [ + { + options: {consistency: 'eventual', readTime: 77000}, + expectedError: + 'Read time and read consistency cannot both be specified.', + description: + 'should error when read time and eventual consistency are specified', + }, + { + options: {consistency: 'eventual'}, + expectedError: + 'Read consistency cannot be specified in a transaction.', + description: + 'should error when new transaction and eventual consistency are specified', + }, + { + options: {readTime: 77000}, + expectedError: 'Read time cannot be specified in a transaction.', + description: + 'should error when new transaction and read time are specified', + }, + ], + (testParameters: { + options: RunQueryOptions; + expectedError: string; + description: string; + }) => { + describe(testParameters.description, () => { + it('should error when runQuery is used', done => { + const transaction = datastore.transaction(); + const query = datastore.createQuery('Task'); + errorOnGapicCall(datastore, clientName, done); // Test fails if Gapic layer receives a call. + transaction.runQuery( + query, + testParameters.options, + getCallbackExpectingError(done, testParameters.expectedError), + ); + }); + it('should error when runQueryStream is used', done => { + const transaction = datastore.transaction(); + const query = datastore.createQuery('Task'); + errorOnGapicCall(datastore, clientName, done); // Test fails if Gapic layer receives a call. + try { + transaction.runQueryStream(query, testParameters.options); + done(new Error('runQueryStream should have thrown an error')); + } catch (err: any) { + assert.strictEqual(err.message, testParameters.expectedError); + done(); + } + }); + it('should error when runAggregationQuery is used', done => { + const transaction = datastore.transaction(); + const query = datastore.createQuery('Task'); + const aggregate = datastore + .createAggregationQuery(query) + .addAggregation(AggregateField.sum('appearances')); + errorOnGapicCall(datastore, clientName, done); // Test fails if Gapic layer receives a call. + transaction.runAggregationQuery( + aggregate, + testParameters.options, + getCallbackExpectingError(done, testParameters.expectedError), + ); + }); + it('should error when get is used', done => { + const transaction = datastore.transaction(); + const keys = datastore.key(['Company', 'Google']); + errorOnGapicCall(datastore, clientName, done); // Test fails if Gapic layer receives a call. + transaction.get( + keys, + testParameters.options, + getCallbackExpectingError(done, testParameters.expectedError), + ); + }); + it('should error when createReadStream is used', done => { + const transaction = datastore.transaction(); + const keys = datastore.key(['Company', 'Google']); + errorOnGapicCall(datastore, clientName, done); // Test fails if Gapic layer receives a call. + try { + transaction.createReadStream(keys, testParameters.options); + done(new Error('createReadStream should have thrown an error')); + } catch (err: any) { + assert.strictEqual(err.message, testParameters.expectedError); + done(); + } + }); + }); + }, + ); + }); +}); diff --git a/handwritten/nodejs-datastore/test/gapic-mocks/runQuery.ts b/handwritten/nodejs-datastore/test/gapic-mocks/runQuery.ts new file mode 100644 index 00000000000..1710d2a6354 --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic-mocks/runQuery.ts @@ -0,0 +1,81 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as assert from 'assert'; +import {describe} from 'mocha'; +import {DatastoreClient} from '../../src'; +import * as protos from '../../protos/protos'; +import {getInitializedDatastoreClient} from './get-initialized-datastore-client'; + +describe('Run Query', () => { + const clientName = 'DatastoreClient'; + const datastore = getInitializedDatastoreClient(); + + // This function is used for doing assertion checks. + // The idea is to check that the right request gets passed to the commit function in the Gapic layer. + function setRunQueryComparison( + compareFn: (request: protos.google.datastore.v1.IRunQueryRequest) => void, + ) { + const dataClient = datastore.clients_.get(clientName); + if (dataClient) { + dataClient.runQuery = ( + request: any, + options: any, + callback: ( + err?: unknown, + res?: protos.google.datastore.v1.IRunQueryResponse, + ) => void, + ) => { + try { + compareFn(request); + } catch (e) { + callback(e); + } + callback(null, { + batch: { + moreResults: + protos.google.datastore.v1.QueryResultBatch.MoreResultsType + .NO_MORE_RESULTS, + }, + }); + }; + } + } + + it('should pass new transaction into runQuery for transactions', async () => { + setRunQueryComparison( + (request: protos.google.datastore.v1.IRunQueryRequest) => { + assert.deepStrictEqual(request, { + readOptions: { + consistencyType: 'newTransaction', + newTransaction: {}, + }, + partitionId: { + namespaceId: 'namespace', + }, + query: { + distinctOn: [], + kind: [{name: 'Task'}], + order: [], + projection: [], + }, + projectId: 'project-id', + }); + }, + ); + const transaction = datastore.transaction(); + const query = datastore.createQuery('Task'); + await transaction.runQuery(query); + }); +}); diff --git a/handwritten/nodejs-datastore/test/gapic_datastore_admin_v1.ts b/handwritten/nodejs-datastore/test/gapic_datastore_admin_v1.ts new file mode 100644 index 00000000000..33169355de8 --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic_datastore_admin_v1.ts @@ -0,0 +1,1884 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 datastoreadminModule from '../src'; + +import {PassThrough} from 'stream'; + +import {protobuf, LROperation, operationsProtos} 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.DatastoreAdminClient', () => { + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'datastore.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = + datastoreadminModule.v1.DatastoreAdminClient.servicePath; + assert.strictEqual(servicePath, 'datastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = + datastoreadminModule.v1.DatastoreAdminClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'datastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.example.com'); + }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new datastoreadminModule.v1.DatastoreAdminClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new datastoreadminModule.v1.DatastoreAdminClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); + }); + + it('has port', () => { + const port = datastoreadminModule.v1.DatastoreAdminClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreAdminStub, undefined); + await client.initialize(); + assert(client.datastoreAdminStub); + }); + + it('has close method for the initialized client', done => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize().catch((err: any) => { + throw err; + }); + assert(client.datastoreAdminStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreAdminStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.GetIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.GetIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.admin.v1.Index(), + ); + client.innerApiCalls.getIndex = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.getIndex( + request, + ( + err?: Error | null, + result?: protos.google.datastore.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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.GetIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; + 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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.GetIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.GetIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.getIndex(request), expectedError); + }); + }); + + describe('exportEntities', () => { + it('invokes exportEntities without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ExportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportEntities = + stubLongRunningCall(expectedResponse); + const [operation] = await client.exportEntities(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportEntities without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ExportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.exportEntities = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.exportEntities( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.datastore.admin.v1.IExportEntitiesResponse, + protos.google.datastore.admin.v1.IExportEntitiesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportEntities with call error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ExportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportEntities = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.exportEntities(request), expectedError); + const actualRequest = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes exportEntities with LRO error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ExportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ExportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.exportEntities = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.exportEntities(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.exportEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkExportEntitiesProgress without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.checkExportEntitiesProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkExportEntitiesProgress with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkExportEntitiesProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('importEntities', () => { + it('invokes importEntities without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ImportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.importEntities = + stubLongRunningCall(expectedResponse); + const [operation] = await client.importEntities(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importEntities without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ImportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.importEntities = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.importEntities( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.protobuf.IEmpty, + protos.google.datastore.admin.v1.IImportEntitiesMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importEntities with call error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ImportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importEntities = stubLongRunningCall( + undefined, + expectedError, + ); + await assert.rejects(client.importEntities(request), expectedError); + const actualRequest = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes importEntities with LRO error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ImportEntitiesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ImportEntitiesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.importEntities = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.importEntities(request); + await assert.rejects(operation.promise(), expectedError); + const actualRequest = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.importEntities as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes checkImportEntitiesProgress without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.checkImportEntitiesProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkImportEntitiesProgress with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects( + client.checkImportEntitiesProgress(''), + expectedError, + ); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('createIndex', () => { + it('invokes createIndex without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.CreateIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.CreateIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.CreateIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.CreateIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${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< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >; + 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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.CreateIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.CreateIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.CreateIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.CreateIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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('deleteIndex', () => { + it('invokes deleteIndex without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.DeleteIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteIndex = stubLongRunningCall(expectedResponse); + const [operation] = await client.deleteIndex(request); + const [response] = await operation.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 without error using callback', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.DeleteIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation(), + ); + client.innerApiCalls.deleteIndex = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.deleteIndex( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + > | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const operation = (await promise) as LROperation< + protos.google.datastore.admin.v1.IIndex, + protos.google.datastore.admin.v1.IIndexOperationMetadata + >; + const [response] = await operation.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 call error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.DeleteIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubLongRunningCall( + 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 LRO error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.DeleteIndexRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const defaultValue2 = getTypeDefaultValue( + '.google.datastore.admin.v1.DeleteIndexRequest', + ['indexId'], + ); + request.indexId = defaultValue2; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}&index_id=${defaultValue2 ?? ''}`; + const expectedError = new Error('expected'); + client.innerApiCalls.deleteIndex = stubLongRunningCall( + undefined, + undefined, + expectedError, + ); + const [operation] = await client.deleteIndex(request); + await assert.rejects(operation.promise(), 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 checkDeleteIndexProgress without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.checkDeleteIndexProgress( + expectedResponse.name, + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkDeleteIndexProgress with error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.checkDeleteIndexProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + + describe('listIndexes', () => { + it('invokes listIndexes without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ListIndexesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ListIndexesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ListIndexesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ListIndexesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + ]; + client.innerApiCalls.listIndexes = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.listIndexes( + request, + ( + err?: Error | null, + result?: protos.google.datastore.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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ListIndexesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ListIndexesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ListIndexesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ListIndexesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.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.datastore.admin.v1.Index[] = []; + stream.on( + 'data', + (response: protos.google.datastore.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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ListIndexesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ListIndexesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${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.datastore.admin.v1.Index[] = []; + stream.on( + 'data', + (response: protos.google.datastore.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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ListIndexesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ListIndexesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${defaultValue1 ?? ''}`; + const expectedResponse = [ + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + generateSampleMessage(new protos.google.datastore.admin.v1.Index()), + ]; + client.descriptors.page.listIndexes.asyncIterate = + stubAsyncIterationCall(expectedResponse); + const responses: protos.google.datastore.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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.admin.v1.ListIndexesRequest(), + ); + const defaultValue1 = getTypeDefaultValue( + '.google.datastore.admin.v1.ListIndexesRequest', + ['projectId'], + ); + request.projectId = defaultValue1; + const expectedHeaderRequestParams = `project_id=${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.datastore.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('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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 datastoreadminModule.v1.DatastoreAdminClient({ + 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.IOperation[] = []; + 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 datastoreadminModule.v1.DatastoreAdminClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); +}); diff --git a/handwritten/nodejs-datastore/test/gapic_datastore_v1.ts b/handwritten/nodejs-datastore/test/gapic_datastore_v1.ts new file mode 100644 index 00000000000..23c97b88c0e --- /dev/null +++ b/handwritten/nodejs-datastore/test/gapic_datastore_v1.ts @@ -0,0 +1,1503 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** 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 datastoreModule from '../src'; + +import {protobuf, operationsProtos} 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 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.DatastoreClient', () => { + describe('Common methods', () => { + it('has apiEndpoint', () => { + const client = new datastoreModule.v1.DatastoreClient(); + const apiEndpoint = client.apiEndpoint; + assert.strictEqual(apiEndpoint, 'datastore.googleapis.com'); + }); + + it('has universeDomain', () => { + const client = new datastoreModule.v1.DatastoreClient(); + const universeDomain = client.universeDomain; + assert.strictEqual(universeDomain, 'googleapis.com'); + }); + + if ( + typeof process === 'object' && + typeof process.emitWarning === 'function' + ) { + it('throws DeprecationWarning if static servicePath is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const servicePath = datastoreModule.v1.DatastoreClient.servicePath; + assert.strictEqual(servicePath, 'datastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + + it('throws DeprecationWarning if static apiEndpoint is used', () => { + const stub = sinon.stub(process, 'emitWarning'); + const apiEndpoint = datastoreModule.v1.DatastoreClient.apiEndpoint; + assert.strictEqual(apiEndpoint, 'datastore.googleapis.com'); + assert(stub.called); + stub.restore(); + }); + } + it('sets apiEndpoint according to universe domain camelCase', () => { + const client = new datastoreModule.v1.DatastoreClient({ + universeDomain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.example.com'); + }); + + it('sets apiEndpoint according to universe domain snakeCase', () => { + const client = new datastoreModule.v1.DatastoreClient({ + universe_domain: 'example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.example.com'); + }); + + if (typeof process === 'object' && 'env' in process) { + describe('GOOGLE_CLOUD_UNIVERSE_DOMAIN environment variable', () => { + it('sets apiEndpoint from environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new datastoreModule.v1.DatastoreClient(); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + + it('value configured in code has priority over environment variable', () => { + const saved = process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = 'example.com'; + const client = new datastoreModule.v1.DatastoreClient({ + universeDomain: 'configured.example.com', + }); + const servicePath = client.apiEndpoint; + assert.strictEqual(servicePath, 'datastore.configured.example.com'); + if (saved) { + process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN'] = saved; + } else { + delete process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']; + } + }); + }); + } + it('does not allow setting both universeDomain and universe_domain', () => { + assert.throws(() => { + new datastoreModule.v1.DatastoreClient({ + universe_domain: 'example.com', + universeDomain: 'example.net', + }); + }); + }); + + it('has port', () => { + const port = datastoreModule.v1.DatastoreClient.port; + assert(port); + assert(typeof port === 'number'); + }); + + it('should create a client with no option', () => { + const client = new datastoreModule.v1.DatastoreClient(); + assert(client); + }); + + it('should create a client with gRPC fallback', () => { + const client = new datastoreModule.v1.DatastoreClient({ + fallback: true, + }); + assert(client); + }); + + it('has initialize method and supports deferred initialization', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreStub, undefined); + await client.initialize(); + assert(client.datastoreStub); + }); + + it('has close method for the initialized client', done => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize().catch((err: any) => { + throw err; + }); + assert(client.datastoreStub); + client.close().then(() => { + done(); + }); + }); + + it('has close method for the non-initialized client', done => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + assert.strictEqual(client.datastoreStub, undefined); + client.close().then(() => { + done(); + }); + }); + + it('has getProjectId method', async () => { + const fakeProjectId = 'fake-project-id'; + const client = new datastoreModule.v1.DatastoreClient({ + 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 datastoreModule.v1.DatastoreClient({ + 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('lookup', () => { + it('invokes lookup without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.LookupRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.LookupResponse(), + ); + client.innerApiCalls.lookup = stubSimpleCall(expectedResponse); + const [response] = await client.lookup(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes lookup without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.LookupRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.LookupResponse(), + ); + client.innerApiCalls.lookup = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.lookup( + request, + ( + err?: Error | null, + result?: protos.google.datastore.v1.ILookupResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes lookup with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.LookupRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.lookup = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.lookup(request), expectedError); + const actualRequest = (client.innerApiCalls.lookup as SinonStub).getCall( + 0, + ).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.lookup as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes lookup with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.LookupRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.lookup(request), expectedError); + }); + }); + + describe('runQuery', () => { + it('invokes runQuery without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.RunQueryResponse(), + ); + client.innerApiCalls.runQuery = stubSimpleCall(expectedResponse); + const [response] = await client.runQuery(request); + 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 without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.RunQueryResponse(), + ); + client.innerApiCalls.runQuery = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runQuery( + request, + ( + err?: Error | null, + result?: protos.google.datastore.v1.IRunQueryResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.runQuery = stubSimpleCall(undefined, expectedError); + await assert.rejects(client.runQuery(request), 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runQuery(request), expectedError); + }); + }); + + describe('runAggregationQuery', () => { + it('invokes runAggregationQuery without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunAggregationQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.RunAggregationQueryResponse(), + ); + client.innerApiCalls.runAggregationQuery = + stubSimpleCall(expectedResponse); + const [response] = await client.runAggregationQuery(request); + 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 without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunAggregationQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.RunAggregationQueryResponse(), + ); + client.innerApiCalls.runAggregationQuery = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.runAggregationQuery( + request, + ( + err?: Error | null, + result?: protos.google.datastore.v1.IRunAggregationQueryResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunAggregationQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.runAggregationQuery = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.runAggregationQuery(request), 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RunAggregationQueryRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.runAggregationQuery(request), expectedError); + }); + }); + + describe('beginTransaction', () => { + it('invokes beginTransaction without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.BeginTransactionRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.BeginTransactionRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.BeginTransactionResponse(), + ); + client.innerApiCalls.beginTransaction = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.beginTransaction( + request, + ( + err?: Error | null, + result?: protos.google.datastore.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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.BeginTransactionRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.BeginTransactionRequest(), + ); + // path template is empty + request.databaseId = 'value'; + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.CommitRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.CommitRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.CommitResponse(), + ); + client.innerApiCalls.commit = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.commit( + request, + ( + err?: Error | null, + result?: protos.google.datastore.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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.CommitRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.CommitRequest(), + ); + // path template is empty + request.databaseId = 'value'; + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RollbackRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.RollbackResponse(), + ); + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RollbackRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.RollbackResponse(), + ); + client.innerApiCalls.rollback = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.rollback( + request, + ( + err?: Error | null, + result?: protos.google.datastore.v1.IRollbackResponse | 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RollbackRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.RollbackRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.rollback(request), expectedError); + }); + }); + + describe('allocateIds', () => { + it('invokes allocateIds without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.AllocateIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.AllocateIdsResponse(), + ); + client.innerApiCalls.allocateIds = stubSimpleCall(expectedResponse); + const [response] = await client.allocateIds(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.allocateIds as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.allocateIds as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes allocateIds without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.AllocateIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.AllocateIdsResponse(), + ); + client.innerApiCalls.allocateIds = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.allocateIds( + request, + ( + err?: Error | null, + result?: protos.google.datastore.v1.IAllocateIdsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.allocateIds as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.allocateIds as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes allocateIds with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.AllocateIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.allocateIds = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.allocateIds(request), expectedError); + const actualRequest = ( + client.innerApiCalls.allocateIds as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.allocateIds as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes allocateIds with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.AllocateIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.allocateIds(request), expectedError); + }); + }); + + describe('reserveIds', () => { + it('invokes reserveIds without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.ReserveIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.ReserveIdsResponse(), + ); + client.innerApiCalls.reserveIds = stubSimpleCall(expectedResponse); + const [response] = await client.reserveIds(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reserveIds as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reserveIds as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reserveIds without error using callback', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.ReserveIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedResponse = generateSampleMessage( + new protos.google.datastore.v1.ReserveIdsResponse(), + ); + client.innerApiCalls.reserveIds = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.reserveIds( + request, + ( + err?: Error | null, + result?: protos.google.datastore.v1.IReserveIdsResponse | null, + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + }, + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.reserveIds as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reserveIds as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reserveIds with error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.ReserveIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedHeaderRequestParams = 'database_id=value'; + const expectedError = new Error('expected'); + client.innerApiCalls.reserveIds = stubSimpleCall( + undefined, + expectedError, + ); + await assert.rejects(client.reserveIds(request), expectedError); + const actualRequest = ( + client.innerApiCalls.reserveIds as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.reserveIds as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes reserveIds with closed client', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await client.initialize(); + const request = generateSampleMessage( + new protos.google.datastore.v1.ReserveIdsRequest(), + ); + // path template is empty + request.databaseId = 'value'; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.reserveIds(request), expectedError); + }); + }); + describe('getOperation', () => { + it('invokes getOperation without error', async () => { + const client = new datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 datastoreModule.v1.DatastoreClient({ + 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 datastoreModule.v1.DatastoreClient({ + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 datastoreModule.v1.DatastoreClient({ + 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 datastoreModule.v1.DatastoreClient({ + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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 datastoreModule.v1.DatastoreClient({ + 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 datastoreModule.v1.DatastoreClient({ + 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 datastoreModule.v1.DatastoreClient({ + 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.IOperation[] = []; + 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 datastoreModule.v1.DatastoreClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + await 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.IOperation[] = []; + for await (const resource of iterable) { + responses.push(resource!); + } + }); + assert.deepStrictEqual( + ( + client.operationsClient.descriptor.listOperations + .asyncIterate as SinonStub + ).getCall(0).args[1], + request, + ); + }); + }); +}); diff --git a/handwritten/nodejs-datastore/test/index-class.ts b/handwritten/nodejs-datastore/test/index-class.ts new file mode 100644 index 00000000000..3754e467274 --- /dev/null +++ b/handwritten/nodejs-datastore/test/index-class.ts @@ -0,0 +1,153 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as promisify from '@google-cloud/promisify'; +import * as assert from 'assert'; +import {before, beforeEach, describe, it} from 'mocha'; +import * as proxyquire from 'proxyquire'; + +import * as ds from '../src'; + +let promisified = false; +const fakePromisify = Object.assign({}, promisify, { + promisifyAll(klass: Function) { + if (klass.name === 'Index') { + promisified = true; + } + }, +}); + +describe('Index', () => { + const INDEX_ID = 'my-index'; + let DATASTORE: ds.Datastore; + + let Index: typeof ds.Index; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let index: any; + + before(() => { + Index = proxyquire('../src/index-class.js', { + '@google-cloud/promisify': fakePromisify, + }).Index; + }); + + beforeEach(() => { + DATASTORE = {} as ds.Datastore; + index = new Index(DATASTORE, INDEX_ID); + }); + + describe('instantiation', () => { + it('should promisify all the things', () => { + assert(promisified); + }); + + it('should localize datastore instance', () => { + assert.strictEqual(index.datastore, DATASTORE); + }); + + it('should localize id from name', () => { + const name = 'long/formatted/name'; + const index = new Index(DATASTORE, name); + assert.strictEqual(index.id, name.split('/').pop()); + }); + + it('should localize id from id', () => { + assert.strictEqual(index.id, INDEX_ID); + }); + }); + + describe('get', () => { + it('should call getMetadata', done => { + const gaxOptions = {}; + index.getMetadata = (options: {}) => { + assert.strictEqual(options, gaxOptions); + done(); + }; + index.get(gaxOptions, assert.ifError); + }); + + it('should not require an options object', done => { + index.getMetadata = (options: {}) => { + assert.deepStrictEqual(options, {}); + done(); + }; + index.get(assert.ifError); + }); + + it('should return an error from getMetadata', done => { + const error = new Error('Error.'); + index.getMetadata = (gaxOptions: {}, callback: Function) => { + callback(error); + }; + index.get((err: Error | null) => { + assert.strictEqual(err, error); + done(); + }); + }); + + it('should return self and API response', done => { + const apiResponse = {}; + index.getMetadata = (gaxOptions: {}, callback: Function) => { + callback(null, apiResponse); + }; + index.get((err: Error | null, _index: {}, _apiResponse: {}) => { + assert.ifError(err); + assert.strictEqual(_index, index); + assert.strictEqual(_apiResponse, apiResponse); + done(); + }); + }); + }); + + describe('getMetadata', () => { + it('should make the correct request', done => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + index.datastore.request_ = (config: any) => { + assert.strictEqual(config.client, 'DatastoreAdminClient'); + assert.strictEqual(config.method, 'getIndex'); + assert.deepStrictEqual(config.reqOpts, { + indexId: index.id, + }); + assert.deepStrictEqual(config.gaxOpts, {}); + done(); + }; + + index.getMetadata(assert.ifError); + }); + + it('should accept gaxOptions', done => { + const gaxOptions = {}; + + index.datastore.request_ = (config: {gaxOpts: {}}) => { + assert.strictEqual(config.gaxOpts, gaxOptions); + done(); + }; + + index.getMetadata(gaxOptions, assert.ifError); + }); + + it('should update the metadata', done => { + const response = {}; + index.datastore.request_ = (config: {}, callback: Function) => { + callback(null, response); + }; + index.getMetadata((err: Error | null, metadata: {}) => { + assert.ifError(err); + assert.strictEqual(metadata, response); + assert.strictEqual(index.metadata, response); + done(); + }); + }); + }); +}); diff --git a/handwritten/nodejs-datastore/test/index.ts b/handwritten/nodejs-datastore/test/index.ts new file mode 100644 index 00000000000..a0074bd7f40 --- /dev/null +++ b/handwritten/nodejs-datastore/test/index.ts @@ -0,0 +1,2747 @@ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as assert from 'assert'; +import {before, beforeEach, after, afterEach, describe, it} from 'mocha'; +import * as gax from 'google-gax'; +import * as proxyquire from 'proxyquire'; +import {PassThrough, Readable} from 'stream'; + +import * as ds from '../src'; +import {AggregateField, Datastore, DatastoreOptions} from '../src'; +import {Datastore as OriginalDatastore} from '../src'; +import { + entity, + Entity, + EntityProto, + EntityObject, + Entities, +} from '../src/entity'; +import {RequestCallback, RequestConfig} from '../src/request'; +import {ExplainOptions, ExplainMetrics, RunQueryInfo} from '../src/query'; +import * as is from 'is'; +import * as sinon from 'sinon'; +import * as extend from 'extend'; +import {google} from '../protos/protos'; +import {ServiceError} from 'google-gax'; + +// eslint-disable-next-line @typescript-eslint/no-var-requires +const v1 = require('../src/v1/index.js'); +const async = require('async'); + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const fakeEntityInit: any = { + KEY_SYMBOL: Symbol('fake key symbol'), + Int: class { + value: {}; + constructor(value: {}) { + this.value = value; + } + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + isDsInt(...args: any[]) { + this.calledWith_ = args; + }, + Double: class { + value: {}; + constructor(value: {}) { + this.value = value; + } + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + isDsDouble(...args: any[]) { + this.calledWith_ = args; + }, + GeoPoint: class { + value: {}; + constructor(value: {}) { + this.value = value; + } + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + isDsGeoPoint(...args: any) { + this.calledWith_ = args; + }, + Key: class { + calledWith_: IArguments; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(...args: any) { + this.calledWith_ = args; + } + }, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + isDsKey(...args: any) { + this.calledWith_ = args; + }, + isKeyComplete: entity.isKeyComplete, + keyFromKeyProto: entity.keyFromKeyProto, + keyToKeyProto: entity.keyToKeyProto, + encodeValue: entity.encodeValue, + entityToEntityProto: entity.entityToEntityProto, + addExcludeFromIndexes: entity.addExcludeFromIndexes, + findLargeProperties_: entity.findLargeProperties_, + URLSafeKey: entity.URLSafeKey, +}; + +const fakeEntity: any = {}; + +let googleAuthOverride: Function | null; +function fakeGoogleAuth(...args: Array<{}>) { + return (googleAuthOverride || (() => {}))(...args); +} + +let createInsecureOverride: Function | null; + +const SECOND_DATABASE_ID = 'multidb-test'; + +export {SECOND_DATABASE_ID}; + +const fakeGoogleGax = { + GoogleAuth: fakeGoogleAuth, + GrpcClient: class extends gax.GrpcClient { + constructor(opts: gax.GrpcClientOptions) { + // super constructor must be called first! + super(opts); + this.grpc = { + credentials: { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + createInsecure(...args: any[]) { + return (createInsecureOverride || (() => {}))(...args); + }, + }, + } as {} as gax.GrpcModule; + } + }, +}; + +class FakeIndex { + calledWith_: Array<{}>; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(...args: any[]) { + this.calledWith_ = args; + } +} + +class FakeQuery { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + calledWith_: any[]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(...args: any[]) { + this.calledWith_ = args; + } +} + +class FakeTransaction { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + calledWith_: any[]; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(...args: any[]) { + this.calledWith_ = args; + } +} + +function FakeV1() {} + +const sandbox = sinon.createSandbox(); + +async.each( + [ + {namespace: `${Date.now()}`}, + {namespace: `second-db-${Date.now()}`, databaseId: SECOND_DATABASE_ID}, + ], + (clientOptions: DatastoreOptions) => { + describe('Datastore', () => { + let Datastore: typeof ds.Datastore; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let datastore: any; + + const PROJECT_ID = 'project-id'; + const NAMESPACE = 'namespace'; + + const DATASTORE_PROJECT_ID_CACHED = process.env.DATASTORE_PROJECT_ID; + + const DEFAULT_OPTIONS = { + projectId: PROJECT_ID, + apiEndpoint: 'http://localhost', + credentials: {}, + keyFilename: 'key/file', + email: 'email', + namespace: NAMESPACE, + }; + + const OPTIONS = Object.assign(DEFAULT_OPTIONS, clientOptions); + + before(() => { + Object.assign(fakeEntity, fakeEntityInit); + const buildEntityProtoModule = proxyquire( + '../src/utils/entity/buildEntityProto.js', + { + '../../entity.js': {entity: fakeEntity}, + }, + ); + Datastore = proxyquire('../src', { + './entity.js': {entity: fakeEntity}, + './index-class.js': {Index: FakeIndex}, + './query.js': {Query: FakeQuery}, + './transaction.js': {Transaction: FakeTransaction}, + './v1': FakeV1, + 'google-auth-library': { + GoogleAuth: fakeGoogleAuth, + }, + 'google-gax': fakeGoogleGax, + './utils/entity/buildEntityProto': buildEntityProtoModule, + }).Datastore; + }); + + beforeEach(() => { + Object.assign(fakeEntity, fakeEntityInit); + + createInsecureOverride = null; + googleAuthOverride = null; + + datastore = new Datastore({ + projectId: PROJECT_ID, + namespace: NAMESPACE, + }); + }); + + afterEach(() => { + if (typeof DATASTORE_PROJECT_ID_CACHED === 'string') { + process.env.DATASTORE_PROJECT_ID = DATASTORE_PROJECT_ID_CACHED; + } else { + delete process.env.DATASTORE_PROJECT_ID; + } + }); + + after(() => { + createInsecureOverride = null; + googleAuthOverride = null; + }); + + it('should export GAX client', () => { + assert.ok(require('../src').v1); + }); + + describe('instantiation', () => { + it('should initialize an empty Client map', () => { + assert(datastore.clients_ instanceof Map); + assert.strictEqual(datastore.clients_.size, 0); + }); + + it('should alias itself to the datastore property', () => { + assert.strictEqual(datastore.datastore, datastore); + }); + + it('should localize the namespace', () => { + assert.strictEqual(datastore.namespace, NAMESPACE); + }); + + it('should localize the projectId', () => { + assert.strictEqual(datastore.options.projectId, PROJECT_ID); + }); + + it('should not default options.projectId to placeholder', () => { + const datastore = new Datastore({}); + assert.strictEqual(datastore.options.projectId, undefined); + }); + + it('should use DATASTORE_PROJECT_ID', () => { + const projectId = 'overridden-project-id'; + process.env.DATASTORE_PROJECT_ID = projectId; + const datastore = new Datastore({}); + assert.strictEqual(datastore.options.projectId, projectId); + }); + + it('should set the default base URL', () => { + assert.strictEqual( + datastore.defaultBaseUrl_, + 'datastore.googleapis.com', + ); + }); + + it('should set default API connection details', done => { + const determineBaseUrl_ = Datastore.prototype.determineBaseUrl_; + + Datastore.prototype.determineBaseUrl_ = customApiEndpoint => { + Datastore.prototype.determineBaseUrl_ = determineBaseUrl_; + + assert.strictEqual(customApiEndpoint, OPTIONS.apiEndpoint); + done(); + }; + + new Datastore(OPTIONS); + }); + + it('should localize the options', () => { + delete process.env.DATASTORE_PROJECT_ID; + + const options = { + a: 'b', + c: 'd', + } as DatastoreOptions; + + const datastore = new Datastore(options); + + assert.notStrictEqual(datastore.options, options); + + assert.deepStrictEqual( + datastore.options, + Object.assign( + { + libName: 'gccl', + libVersion: require('../../package.json').version, + scopes: v1.DatastoreClient.scopes, + servicePath: datastore.baseUrl_, + port: 443, + projectId: undefined, + }, + options, + ), + ); + }); + + it('should set port if detected', () => { + const determineBaseUrl_ = Datastore.prototype.determineBaseUrl_; + const port = 99; + Datastore.prototype.determineBaseUrl_ = function () { + Datastore.prototype.determineBaseUrl_ = determineBaseUrl_; + this.port_ = port; + }; + const datastore = new Datastore(OPTIONS); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + assert.strictEqual((datastore.options as any).port, port); + }); + + it('should set grpc ssl credentials if localhost custom endpoint', () => { + const fakeInsecureCreds = {}; + createInsecureOverride = () => { + return fakeInsecureCreds; + }; + + const datastore = new Datastore(OPTIONS); + + assert.strictEqual(datastore.options.sslCreds, fakeInsecureCreds); + }); + + describe('checking ssl credentials are set correctly with custom endpoints', () => { + function setHost(host: string) { + process.env.DATASTORE_EMULATOR_HOST = host; + } + + const sslCreds = gax.grpc.ChannelCredentials.createSsl(); + const fakeInsecureCreds = { + insecureCredProperty: 'insecureCredPropertyValue', + }; + + beforeEach(() => { + createInsecureOverride = () => { + return fakeInsecureCreds; + }; + }); + + describe('without DATASTORE_EMULATOR_HOST environment variable set', () => { + beforeEach(() => { + delete process.env.DATASTORE_EMULATOR_HOST; + }); + + describe('using a localhost endpoint', () => { + const apiEndpoint = 'http://localhost:8080'; + it('should use ssl credentials provided', () => { + // SSL credentials provided in the constructor should always be used. + const options = { + apiEndpoint, + sslCreds, + }; + const datastore = new Datastore(options); + assert.strictEqual(datastore.options.sslCreds, sslCreds); + }); + it('should use insecure ssl credentials when ssl credentials are not provided', () => { + // When using a localhost endpoint it is assumed that the emulator is being used. + // Therefore, sslCreds should be set to insecure credentials to skip authentication. + const datastore = new Datastore({ + apiEndpoint, + }); + assert.strictEqual( + datastore.options.sslCreds, + fakeInsecureCreds, + ); + }); + }); + describe('using a remote endpoint', () => { + const apiEndpoint = 'http://remote:8080'; + it('should use ssl credentials provided', () => { + // SSL credentials provided in the constructor should always be used. + const options = { + apiEndpoint, + sslCreds, + }; + const datastore = new Datastore(options); + assert.strictEqual(datastore.options.sslCreds, sslCreds); + }); + it('should not set ssl credentials when ssl credentials are not provided', () => { + // When using a remote endpoint without DATASTORE_EMULATOR_HOST set, + // it is assumed that the emulator is not being used. + // This test captures the case where users use a regional endpoint. + const datastore = new Datastore({ + apiEndpoint, + }); + assert.strictEqual(datastore.options.sslCreds, undefined); + }); + }); + }); + describe('with DATASTORE_EMULATOR_HOST environment variable set', () => { + beforeEach(() => { + delete process.env.DATASTORE_EMULATOR_HOST; + }); + + describe('with DATASTORE_EMULATOR_HOST set to localhost', () => { + const apiEndpoint = 'http://localhost:8080'; + beforeEach(() => { + setHost(apiEndpoint); + }); + + it('should use ssl credentials provided', () => { + // SSL credentials provided in the constructor should always be used. + const datastore = new Datastore({ + apiEndpoint, + sslCreds, + }); + assert.strictEqual(datastore.options.sslCreds, sslCreds); + }); + + it('should use insecure ssl credentials when ssl credentials are not provided', () => { + // When DATASTORE_EMULATOR_HOST is set it is assumed that the emulator is being used. + // Therefore, sslCreds should be set to insecure credentials to skip authentication. + const datastore = new Datastore({ + apiEndpoint, + }); + assert.strictEqual( + datastore.options.sslCreds, + fakeInsecureCreds, + ); + }); + }); + + describe('with DATASTORE_EMULATOR_HOST set to remote host', () => { + const apiEndpoint = 'http://remote:8080'; + beforeEach(() => { + setHost(apiEndpoint); + }); + + it('should use ssl credentials provided', () => { + // SSL credentials provided in the constructor should always be used. + const datastore = new Datastore({ + apiEndpoint, + sslCreds, + }); + assert.strictEqual(datastore.options.sslCreds, sslCreds); + }); + + it('should use insecure ssl credentials when ssl credentials are not provided', () => { + // When DATASTORE_EMULATOR_HOST is set it is assumed that the emulator is being used. + // Therefore, sslCreds should be set to insecure credentials to skip authentication. + const datastore = new Datastore({ + apiEndpoint, + }); + assert.strictEqual( + datastore.options.sslCreds, + fakeInsecureCreds, + ); + }); + }); + + after(() => { + delete process.env.DATASTORE_EMULATOR_HOST; + }); + }); + }); + + it('should cache a local GoogleAuth instance', () => { + const fakeGoogleAuthInstance = {}; + + googleAuthOverride = () => { + return fakeGoogleAuthInstance; + }; + + const datastore = new Datastore({}); + assert.strictEqual(datastore.auth, fakeGoogleAuthInstance); + }); + }); + + describe('double', () => { + it('should expose Double builder', () => { + const aDouble = 7.0; + const double = Datastore.double(aDouble); + assert.strictEqual(double.value, aDouble); + }); + + it('should also be on the prototype', () => { + const aDouble = 7.0; + const double = datastore.double(aDouble); + assert.strictEqual(double.value, aDouble); + }); + }); + + describe('geoPoint', () => { + it('should expose GeoPoint builder', () => { + const aGeoPoint = {latitude: 24, longitude: 88}; + const geoPoint = Datastore.geoPoint(aGeoPoint); + assert.strictEqual(geoPoint.value, aGeoPoint); + }); + + it('should also be on the prototype', () => { + const aGeoPoint = {latitude: 24, longitude: 88}; + const geoPoint = datastore.geoPoint(aGeoPoint); + assert.strictEqual(geoPoint.value, aGeoPoint); + }); + }); + + describe('int', () => { + it('should expose Int builder', () => { + const anInt = 7; + const int = Datastore.int(anInt); + assert.strictEqual(int.value, anInt); + }); + + it('should also be on the prototype', () => { + const anInt = 7; + const int = datastore.int(anInt); + assert.strictEqual(int.value, anInt); + }); + }); + + describe('isDouble', () => { + it('should pass value to entity', () => { + const value = 0.42; + let called = false; + const saved = fakeEntity.isDsDouble; + fakeEntity.isDsDouble = (arg: {}) => { + assert.strictEqual(arg, value); + called = true; + return false; + }; + assert.strictEqual(datastore.isDouble(value), false); + assert.strictEqual(called, true); + fakeEntity.isDsDouble = saved; + }); + + it('should expose Double identifier', () => { + const something = {}; + Datastore.isDouble(something); + assert.strictEqual(fakeEntity.calledWith_[0], something); + }); + }); + + describe('isGeoPoint', () => { + it('should pass value to entity', () => { + const value = {fakeLatitude: 1, fakeLongitude: 2}; + let called = false; + const saved = fakeEntity.isDsGeoPoint; + fakeEntity.isDsGeoPoint = (arg: {}) => { + assert.strictEqual(arg, value); + called = true; + return false; + }; + assert.strictEqual(datastore.isGeoPoint(value), false); + assert.strictEqual(called, true); + fakeEntity.isDsGeoPoint = saved; + }); + + it('should expose GeoPoint identifier', () => { + const something = {}; + Datastore.isGeoPoint(something); + assert.strictEqual(fakeEntity.calledWith_[0], something); + }); + }); + + describe('isInt', () => { + it('should pass value to entity', () => { + const value = 42; + let called = false; + const saved = fakeEntity.isDsInt; + fakeEntity.isDsInt = (arg: {}) => { + assert.strictEqual(arg, value); + called = true; + return false; + }; + assert.strictEqual(datastore.isInt(value), false); + assert.strictEqual(called, true); + fakeEntity.isDsInt = saved; + }); + + it('should expose Int identifier', () => { + const something = {}; + Datastore.isInt(something); + assert.strictEqual(fakeEntity.calledWith_[0], something); + }); + }); + + describe('isKey', () => { + it('should pass value to entity', () => { + const value = {zz: true}; + let called = false; + const saved = fakeEntity.isDsKey; + fakeEntity.isDsKey = (arg: {}) => { + assert.strictEqual(arg, value); + called = true; + return false; + }; + assert.strictEqual(datastore.isKey(value), false); + assert.strictEqual(called, true); + fakeEntity.isDsKey = saved; + }); + + it('should expose Key identifier', () => { + const something = {}; + datastore.isKey(something); + assert.strictEqual(fakeEntity.calledWith_[0], something); + }); + }); + + describe('KEY', () => { + it('should expose the KEY symbol', () => { + assert.strictEqual(Datastore.KEY, fakeEntity.KEY_SYMBOL); + }); + + it('should also be on the prototype', () => { + assert.strictEqual(datastore.KEY, Datastore.KEY); + }); + }); + + describe('MORE_RESULTS_AFTER_CURSOR', () => { + it('should expose a MORE_RESULTS_AFTER_CURSOR helper', () => { + assert.strictEqual( + Datastore.MORE_RESULTS_AFTER_CURSOR, + 'MORE_RESULTS_AFTER_CURSOR', + ); + }); + + it('should also be on the prototype', () => { + assert.strictEqual( + datastore.MORE_RESULTS_AFTER_CURSOR, + Datastore.MORE_RESULTS_AFTER_CURSOR, + ); + }); + }); + + describe('MORE_RESULTS_AFTER_LIMIT', () => { + it('should expose a MORE_RESULTS_AFTER_LIMIT helper', () => { + assert.strictEqual( + Datastore.MORE_RESULTS_AFTER_LIMIT, + 'MORE_RESULTS_AFTER_LIMIT', + ); + }); + + it('should also be on the prototype', () => { + assert.strictEqual( + datastore.MORE_RESULTS_AFTER_LIMIT, + Datastore.MORE_RESULTS_AFTER_LIMIT, + ); + }); + }); + + describe('NO_MORE_RESULTS', () => { + it('should expose a NO_MORE_RESULTS helper', () => { + assert.strictEqual(Datastore.NO_MORE_RESULTS, 'NO_MORE_RESULTS'); + }); + + it('should also be on the prototype', () => { + assert.strictEqual( + datastore.NO_MORE_RESULTS, + Datastore.NO_MORE_RESULTS, + ); + }); + }); + + describe('createQuery', () => { + it('should return a Query object', () => { + const namespace = 'namespace'; + const kind = ['Kind']; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const query: any = datastore.createQuery(namespace, kind); + assert(query instanceof FakeQuery); + + assert.strictEqual(query.calledWith_[0], datastore); + assert.strictEqual(query.calledWith_[1], namespace); + assert.deepStrictEqual(query.calledWith_[2], kind); + }); + + it('should include the default namespace', () => { + const kind = ['Kind']; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const query: any = datastore.createQuery(kind); + assert.strictEqual(query.calledWith_[0], datastore); + assert.strictEqual(query.calledWith_[1], datastore.namespace); + assert.deepStrictEqual(query.calledWith_[2], kind); + }); + + it('should include the default namespace in a kindless query', () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const query: any = datastore.createQuery(); + assert.strictEqual(query.calledWith_[0], datastore); + assert.strictEqual(query.calledWith_[1], datastore.namespace); + assert.deepStrictEqual(query.calledWith_[2], []); + }); + }); + + describe('export', () => { + it('should accept a bucket string destination', done => { + const bucket = 'bucket'; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual( + config.reqOpts.outputUrlPrefix, + `gs://${bucket}`, + ); + done(); + }; + + datastore.export({bucket}, assert.ifError); + }); + + it('should remove extraneous gs:// prefix from input', done => { + const bucket = 'gs://bucket'; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.reqOpts.outputUrlPrefix, `${bucket}`); + done(); + }; + + datastore.export({bucket}, assert.ifError); + }); + + it('should accept a Bucket object destination', done => { + const bucket = {name: 'bucket'}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual( + config.reqOpts.outputUrlPrefix, + `gs://${bucket.name}`, + ); + done(); + }; + + datastore.export({bucket}, assert.ifError); + }); + + it('should throw if a destination is not provided', () => { + assert.throws(() => { + datastore.export({}, assert.ifError); + }, /A Bucket object or URL must be provided\./); + }); + + it('should throw if bucket and outputUrlPrefix are provided', () => { + assert.throws(() => { + datastore.export( + { + bucket: 'bucket', + outputUrlPrefix: 'output-url-prefix', + }, + assert.ifError, + ); + }, /Both `bucket` and `outputUrlPrefix` were provided\./); + }); + + it('should accept kinds', done => { + const kinds = ['kind1', 'kind2']; + const config = {bucket: 'bucket', kinds}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.deepStrictEqual(config.reqOpts.entityFilter.kinds, kinds); + done(); + }; + + datastore.export(config, assert.ifError); + }); + + it('should throw if both kinds and entityFilter are provided', () => { + assert.throws(() => { + datastore.export( + { + bucket: 'bucket', + kinds: ['kind1', 'kind2'], + entityFilter: {}, + }, + assert.ifError, + ); + }, /Both `entityFilter` and `kinds` were provided\./); + }); + + it('should accept namespaces', done => { + const namespaces = ['ns1', 'n2']; + const config = {bucket: 'bucket', namespaces}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.deepStrictEqual( + config.reqOpts.entityFilter.namespaceIds, + namespaces, + ); + done(); + }; + + datastore.export(config, assert.ifError); + }); + + it('should throw if both namespaces and entityFilter are provided', () => { + assert.throws(() => { + datastore.export( + { + bucket: 'bucket', + namespaces: ['ns1', 'ns2'], + entityFilter: {}, + }, + assert.ifError, + ); + }, /Both `entityFilter` and `namespaces` were provided\./); + }); + + it('should remove extraneous properties from request', done => { + const config = { + bucket: 'bucket', + gaxOptions: {}, + kinds: ['kind1', 'kind2'], + namespaces: ['ns1', 'ns2'], + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(typeof config.reqOpts.bucket, 'undefined'); + assert.strictEqual(typeof config.reqOpts.gaxOptions, 'undefined'); + assert.strictEqual(typeof config.reqOpts.kinds, 'undefined'); + assert.strictEqual(typeof config.reqOpts.namespaces, 'undefined'); + done(); + }; + + datastore.export(config, assert.ifError); + }); + + it('should send any user input to API', done => { + const userProperty = 'abc'; + const config = {bucket: 'bucket', userProperty}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.reqOpts.userProperty, userProperty); + done(); + }; + + datastore.export(config, assert.ifError); + }); + + it('should send correct request', done => { + const config = {bucket: 'bucket'}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.client, 'DatastoreAdminClient'); + assert.strictEqual(config.method, 'exportEntities'); + assert.strictEqual(typeof config.gaxOpts, 'undefined'); + done(); + }; + + datastore.export(config, assert.ifError); + }); + + it('should accept gaxOptions', done => { + const gaxOptions = {}; + const config = {bucket: 'bucket', gaxOptions}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.gaxOpts, gaxOptions); + done(); + }; + + datastore.export(config, assert.ifError); + }); + }); + + describe('getIndexes', () => { + it('should send the correct request', done => { + const options = {a: 'b'}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.client, 'DatastoreAdminClient'); + assert.strictEqual(config.method, 'listIndexes'); + assert.deepStrictEqual(config.reqOpts, { + pageSize: undefined, + pageToken: undefined, + ...options, + }); + assert.deepStrictEqual(config.gaxOpts, {}); + + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should locate pagination settings from gaxOptions', done => { + const options = { + gaxOptions: { + pageSize: 'size', + pageToken: 'token', + }, + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual( + config.reqOpts.pageSize, + options.gaxOptions.pageSize, + ); + assert.strictEqual( + config.reqOpts.pageToken, + options.gaxOptions.pageToken, + ); + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should prefer pageSize and pageToken from options over gaxOptions', done => { + const options = { + pageSize: 'size-good', + pageToken: 'token-good', + gaxOptions: { + pageSize: 'size-bad', + pageToken: 'token-bad', + }, + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.reqOpts.pageSize, options.pageSize); + assert.strictEqual(config.reqOpts.pageToken, options.pageToken); + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should remove extraneous pagination settings from request', done => { + const options = { + gaxOptions: { + pageSize: 'size', + pageToken: 'token', + }, + autoPaginate: true, + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(typeof config.gaxOpts.pageSize, 'undefined'); + assert.strictEqual(typeof config.gaxOpts.pageToken, 'undefined'); + assert.strictEqual(typeof config.reqOpts.autoPaginate, 'undefined'); + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should accept gaxOptions', done => { + const options = { + gaxOptions: {a: 'b'}, + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(typeof config.reqOpts.gaxOptions, 'undefined'); + assert.deepStrictEqual(config.gaxOpts, options.gaxOptions); + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should not send gaxOptions as request options', done => { + const options = { + gaxOptions: {a: 'b'}, + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert( + Object.keys(options.gaxOptions).every(k => !config.reqOpts[k]), + ); + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should set autoPaginate from options', done => { + const options = { + autoPaginate: true, + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual( + config.gaxOpts.autoPaginate, + options.autoPaginate, + ); + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should prefer autoPaginate from gaxOpts', done => { + const options = { + autoPaginate: false, + gaxOptions: { + autoPaginate: true, + }, + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.gaxOpts.autoPaginate, true); + done(); + }; + + datastore.getIndexes(options, assert.ifError); + }); + + it('should execute callback with error and correct response arguments', done => { + const error = new Error('Error.'); + const apiResponse = {}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any, callback: Function) => { + callback(error, [], null, apiResponse); + }; + + datastore.getIndexes( + (err: Error, indexes: [], nextQuery: {}, apiResp: {}) => { + assert.strictEqual(err, error); + assert.deepStrictEqual(indexes, []); + assert.strictEqual(nextQuery, null); + assert.strictEqual(apiResp, apiResponse); + done(); + }, + ); + }); + + it('should execute callback with Index instances', done => { + const rawIndex = {indexId: 'name', a: 'b'}; + const indexInstance = {}; + + datastore.index = (id: string) => { + assert.strictEqual(id, rawIndex.indexId); + return indexInstance; + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any, callback: Function) => { + callback(null, [rawIndex]); + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.getIndexes((err: Error, indexes: any[]) => { + assert.ifError(err); + assert.deepStrictEqual(indexes, [indexInstance]); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + assert.strictEqual((indexes[0] as any)!.metadata, rawIndex); + done(); + }); + }); + + it('should execute callback with prepared nextQuery', done => { + const options = {pageToken: '1'}; + const nextQuery = {pageToken: '2'}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any, callback: Function) => { + callback(null, [], nextQuery); + }; + + datastore.getIndexes( + options, + (err: Error, indexes: [], _nextQuery: {}) => { + assert.ifError(err); + assert.deepStrictEqual(_nextQuery, nextQuery); + done(); + }, + ); + }); + }); + + describe('getIndexesStream', () => { + it('should make correct request', done => { + const options = {a: 'b'}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.requestStream_ = (config: any) => { + assert.strictEqual(config.client, 'DatastoreAdminClient'); + assert.strictEqual(config.method, 'listIndexesStream'); + assert.deepStrictEqual(config.reqOpts, { + ...options, + }); + assert.strictEqual(typeof config.gaxOpts, 'undefined'); + setImmediate(done); + return new PassThrough(); + }; + + datastore.getIndexesStream(options); + }); + + it('should accept gaxOptions', done => { + const options = {gaxOptions: {}}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.requestStream_ = (config: any) => { + assert.strictEqual(config.gaxOpts, options.gaxOptions); + setImmediate(done); + return new PassThrough(); + }; + + datastore.getIndexesStream(options); + }); + + it('should transform response indexes into Index objects', done => { + const rawIndex = {indexId: 'name', a: 'b'}; + const indexInstance = {}; + const requestStream = new Readable({ + objectMode: true, + read() { + this.push(rawIndex); + this.push(null); + }, + }); + + datastore.index = (id: string) => { + assert.strictEqual(id, rawIndex.indexId); + return indexInstance; + }; + + datastore.requestStream_ = () => requestStream; + + datastore + .getIndexesStream() + .on('error', done) + // eslint-disable-next-line @typescript-eslint/no-explicit-any + .on('data', (index: any) => { + assert.strictEqual(index, indexInstance); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + assert.strictEqual((index as any).metadata, rawIndex); + done(); + }); + }); + }); + + describe('import', () => { + it('should throw if both file and inputUrl are provided', () => { + assert.throws(() => { + datastore.import( + { + file: 'file', + inputUrl: 'gs://file', + }, + assert.ifError, + ); + }, /Both `file` and `inputUrl` were provided\./); + }); + + it('should accept a file string source', done => { + const file = 'file'; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.reqOpts.inputUrl, `gs://${file}`); + done(); + }; + + datastore.import({file}, assert.ifError); + }); + + it('should remove extraneous gs:// prefix from input', done => { + const file = 'gs://file'; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.reqOpts.inputUrl, `${file}`); + done(); + }; + + datastore.import({file}, assert.ifError); + }); + + it('should accept a File object source', done => { + const file = {bucket: {name: 'bucket'}, name: 'file'}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual( + config.reqOpts.inputUrl, + `gs://${file.bucket.name}/${file.name}`, + ); + done(); + }; + + datastore.import({file}, assert.ifError); + }); + + it('should throw if a source is not provided', () => { + assert.throws(() => { + datastore.import({}, assert.ifError); + }, /An input URL must be provided\./); + }); + + it('should accept kinds', done => { + const kinds = ['kind1', 'kind2']; + const config = {file: 'file', kinds}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.deepStrictEqual(config.reqOpts.entityFilter.kinds, kinds); + done(); + }; + + datastore.import(config, assert.ifError); + }); + + it('should throw if both kinds and entityFilter are provided', () => { + assert.throws(() => { + datastore.import( + { + file: 'file', + kinds: ['kind1', 'kind2'], + entityFilter: {}, + }, + assert.ifError, + ); + }, /Both `entityFilter` and `kinds` were provided\./); + }); + + it('should accept namespaces', done => { + const namespaces = ['ns1', 'n2']; + const config = {file: 'file', namespaces}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.deepStrictEqual( + config.reqOpts.entityFilter.namespaceIds, + namespaces, + ); + done(); + }; + + datastore.import(config, assert.ifError); + }); + + it('should throw if both namespaces and entityFilter are provided', () => { + assert.throws(() => { + datastore.import( + { + file: 'file', + namespaces: ['ns1', 'ns2'], + entityFilter: {}, + }, + assert.ifError, + ); + }, /Both `entityFilter` and `namespaces` were provided\./); + }); + + it('should remove extraneous properties from request', done => { + const config = { + file: 'file', + gaxOptions: {}, + kinds: ['kind1', 'kind2'], + namespaces: ['ns1', 'ns2'], + }; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(typeof config.reqOpts.file, 'undefined'); + assert.strictEqual(typeof config.reqOpts.gaxOptions, 'undefined'); + assert.strictEqual(typeof config.reqOpts.kinds, 'undefined'); + assert.strictEqual(typeof config.reqOpts.namespaces, 'undefined'); + done(); + }; + + datastore.import(config, assert.ifError); + }); + + it('should send any user input to API', done => { + const userProperty = 'abc'; + const config = {file: 'file', userProperty}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.reqOpts.userProperty, userProperty); + done(); + }; + + datastore.import(config, assert.ifError); + }); + + it('should send correct request', done => { + const config = {file: 'file'}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.client, 'DatastoreAdminClient'); + assert.strictEqual(config.method, 'importEntities'); + assert.strictEqual(typeof config.gaxOpts, 'undefined'); + done(); + }; + + datastore.import(config, assert.ifError); + }); + + it('should accept gaxOptions', done => { + const gaxOptions = {}; + const config = {file: 'file', gaxOptions}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + datastore.request_ = (config: any) => { + assert.strictEqual(config.gaxOpts, gaxOptions); + done(); + }; + + datastore.import(config, assert.ifError); + }); + }); + + describe('index', () => { + it('should return an Index object', () => { + const indexId = 'index-id'; + const index = datastore.index(indexId); + assert(index instanceof FakeIndex); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const args = (index as any).calledWith_; + assert.strictEqual(args[0], datastore); + assert.strictEqual(args[1], indexId); + }); + }); + + describe('insert', () => { + afterEach(() => { + sandbox.restore(); + }); + + it('should prepare entity objects', done => { + const entityObject = {}; + const preparedEntityObject = {prepared: true}; + const expectedEntityObject = Object.assign({}, preparedEntityObject, { + method: 'insert', + }); + + sandbox + .stub(ds.DatastoreRequest, 'prepareEntityObject_') + .callsFake(obj => { + assert.strictEqual(obj, entityObject); + return preparedEntityObject as {}; + }); + + datastore.save = (entities: Entity[]) => { + assert.deepStrictEqual(entities[0], expectedEntityObject); + done(); + }; + + datastore.insert(entityObject, assert.ifError); + }); + + it('should pass the correct arguments to save', done => { + datastore.save = (entities: Entity[], callback: Function) => { + assert.deepStrictEqual(JSON.parse(JSON.stringify(entities)), [ + { + key: { + namespace: 'ns', + kind: 'Company', + path: ['Company', null], + }, + data: {}, + method: 'insert', + }, + ]); + callback(); + }; + const key = new entity.Key({namespace: 'ns', path: ['Company']}); + datastore.insert({key, data: {}}, done); + }); + }); + + describe('key', () => { + it('should return a Key object', () => { + const options = {} as entity.KeyOptions; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const key: any = datastore.key(options); + assert.strictEqual(key.calledWith_[0], options); + }); + + it('should use a non-object argument as the path', () => { + const options = 'path'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const key: any = datastore.key(options); + assert.strictEqual(key.calledWith_[0].namespace, datastore.namespace); + assert.deepStrictEqual(key.calledWith_[0].path, [options]); + }); + }); + + describe('save', () => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + type Any = any; + let key: entity.Key; + + beforeEach(() => { + key = new entity.Key({ + namespace: 'namespace', + path: ['Company', 123], + }); + }); + + afterEach(() => { + sandbox.restore(); + }); + + it('should save with keys', done => { + const expectedReq = { + mutations: [ + { + upsert: { + key: { + partitionId: { + namespaceId: 'namespace', + }, + path: [ + { + kind: 'Company', + id: 123, + }, + ], + }, + properties: { + k: { + stringValue: 'v', + }, + }, + }, + }, + { + upsert: { + key: { + partitionId: { + namespaceId: 'namespace', + }, + path: [ + { + kind: 'Company', + id: 123, + }, + ], + }, + properties: { + k: { + stringValue: 'v', + }, + }, + }, + }, + ], + }; + + datastore.request_ = (config: RequestConfig, callback: Function) => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'commit'); + + assert.deepStrictEqual(config.reqOpts, expectedReq); + assert.deepStrictEqual(config.gaxOpts, {}); + + callback(); + }; + datastore.save( + [ + {key, data: {k: 'v'}}, + {key, data: {k: 'v'}}, + ], + done, + ); + }); + + it('should save null value when excludeLargeProperties enabled', done => { + const expectedProperties = { + stringField: { + stringValue: 'string value', + }, + nullField: { + nullValue: 0, + }, + arrayField: { + arrayValue: { + values: [ + { + integerValue: '0', + }, + { + nullValue: 0, + }, + ], + }, + }, + objectField: { + nullValue: 0, + }, + }; + + datastore.request_ = (config: RequestConfig, callback: Function) => { + assert.deepStrictEqual( + config.reqOpts!.mutations![0].upsert!.properties, + expectedProperties, + ); + callback(); + }; + + const entities = { + key: key, + data: { + stringField: 'string value', + nullField: null, + arrayField: [0, null], + objectField: null, + }, + excludeLargeProperties: true, + }; + datastore.save(entities, done); + }); + + it('should allow customization of GAX options', done => { + const gaxOptions = {}; + + datastore.request_ = (config: RequestConfig) => { + assert.strictEqual(config.gaxOpts, gaxOptions); + done(); + }; + + datastore.save( + { + key, + data: {}, + }, + gaxOptions, + assert.ifError, + ); + }); + + it('should throw error when value is not provided', done => { + datastore.request_ = (config: RequestConfig) => { + done('Should not reach request_ function'); + }; + + try { + datastore.save( + { + key, + data: [ + { + name: 'something', + }, + ], + }, + () => { + done('Should not reach callback'); + }, + ); + } catch (err: unknown) { + assert.strictEqual( + (err as {message: string}).message, + 'Unsupported field value, undefined, was provided.', + ); + done(); + return; + } + assert.fail('Calling save should have thrown an error'); + }); + + it('should throw error when name property does not support toString method', done => { + datastore.request_ = (config: RequestConfig) => { + done('Should not reach request_ function'); + }; + try { + datastore.save( + { + key, + data: [ + { + name: null, + value: 7, + }, + ], + }, + () => { + done('Should not reach callback'); + }, + ); + } catch (err: unknown) { + assert( + [ + "Cannot read properties of null (reading 'toString')", // Later Node versions + "Cannot read property 'toString' of null", // Node 14 + ].includes((err as {message: string}).message), + ); + done(); + return; + } + assert.fail('Calling save should have thrown an error'); + }); + + it('should prepare entity objects', done => { + const entityObject = {}; + let prepared = false; + + sandbox + .stub(ds.DatastoreRequest, 'prepareEntityObject_') + .callsFake(obj => { + assert.strictEqual(obj, entityObject); + prepared = true; + return { + key, + method: 'insert', + data: {k: 'v'}, + } as {}; + }); + + datastore.request_ = () => { + assert.strictEqual(prepared, true); + done(); + }; + + datastore.save(entityObject, assert.ifError); + }); + + it('should save with specific method', done => { + datastore.request_ = (config: RequestConfig, callback: Function) => { + assert.strictEqual(config.reqOpts!.mutations!.length, 3); + assert(is.object(config.reqOpts!.mutations![0].insert)); + assert(is.object(config.reqOpts!.mutations![1].update)); + assert(is.object(config.reqOpts!.mutations![2].upsert)); + + const insert = config.reqOpts!.mutations![0].insert!; + assert.deepStrictEqual(insert.properties!.k, {stringValue: 'v'}); + + const update = config.reqOpts!.mutations![1].update!; + assert.deepStrictEqual(update.properties!.k2, {stringValue: 'v2'}); + + const upsert = config.reqOpts!.mutations![2].upsert!; + assert.deepStrictEqual(upsert.properties!.k3, {stringValue: 'v3'}); + + callback(); + }; + + datastore.save( + [ + {key, method: 'insert', data: {k: 'v'}}, + {key, method: 'update', data: {k2: 'v2'}}, + {key, method: 'upsert', data: {k3: 'v3'}}, + ], + done, + ); + }); + + it('should throw if a given method is not recognized', () => { + assert.throws(() => { + datastore.save( + { + key, + method: 'auto_insert_id', + data: { + k: 'v', + }, + }, + assert.ifError, + ); + }, /Method auto_insert_id not recognized/); + }); + + it('should not alter the provided data object', done => { + const entities = [ + { + key, + method: 'insert', + indexed: false, + data: { + value: { + a: 'b', + c: [1, 2, 3], + }, + }, + }, + ]; + const expectedEntities = entities.map(x => extend(true, {}, x)); + + datastore.request_ = () => { + // By the time the request is made, the original object has already been + // transformed into a raw request. + assert.deepStrictEqual(entities, expectedEntities); + done(); + }; + + datastore.save(entities, assert.ifError); + }); + + it('should return apiResponse in callback', done => { + const key = new entity.Key({namespace: 'ns', path: ['Company']}); + const mockCommitResponse = {}; + datastore.request_ = (config: RequestConfig, callback: Function) => { + callback(null, mockCommitResponse); + }; + datastore.save( + {key, data: {}}, + (err: Error | null, apiResponse: Entity) => { + assert.ifError(err); + assert.strictEqual(mockCommitResponse, apiResponse); + done(); + }, + ); + }); + + it('should allow setting the indexed value of a property', done => { + datastore.request_ = (config: RequestConfig) => { + const property = + config.reqOpts!.mutations![0].upsert!.properties!.name; + assert.strictEqual(property.stringValue, 'value'); + assert.strictEqual(property.excludeFromIndexes, true); + done(); + }; + + datastore.save( + { + key, + data: [ + { + name: 'name', + value: 'value', + excludeFromIndexes: true, + }, + ], + }, + assert.ifError, + ); + }); + + it('should allow setting the indexed value on arrays', done => { + datastore.request_ = (config: RequestConfig) => { + const property = + config.reqOpts!.mutations![0].upsert!.properties!.name; + + property.arrayValue!.values!.forEach((value: Any) => { + assert.strictEqual(value.excludeFromIndexes, true); + }); + + done(); + }; + + datastore.save( + { + key, + data: [ + { + name: 'name', + value: ['one', 'two', 'three'], + excludeFromIndexes: true, + }, + ], + }, + assert.ifError, + ); + }); + + it('should allow exclude property indexed with "*" wildcard from root', done => { + const longString = Buffer.alloc(1501, '.').toString(); + const data = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + + const validateIndex = (data: Any) => { + if (data.arrayValue) { + data.arrayValue.values.forEach((value: Any) => { + validateIndex(value); + }); + } else if (data.entityValue) { + Object.keys(data.entityValue.properties).forEach(path => { + validateIndex(data.entityValue.properties[path]); + }); + } else { + assert.strictEqual(data.excludeFromIndexes, true); + } + }; + + datastore.request_ = (config: RequestConfig) => { + const properties = config.reqOpts!.mutations![0].upsert!.properties; + Object.keys(properties!).forEach(path => { + validateIndex(properties![path]); + }); + done(); + }; + + datastore.save( + { + key, + data, + excludeFromIndexes: ['.*'], + }, + assert.ifError, + ); + }); + + it('should allow exclude property indexed with "*" wildcard for object and array', done => { + const longString = Buffer.alloc(1501, '.').toString(); + const data = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + + const validateIndex = (data: Any) => { + if (data.arrayValue) { + data.arrayValue.values.forEach((value: Any) => { + validateIndex(value); + }); + } else if (data.entityValue) { + Object.keys(data.entityValue.properties).forEach(path => { + validateIndex(data.entityValue.properties[path]); + }); + } else { + assert.strictEqual(data.excludeFromIndexes, true); + } + }; + + datastore.request_ = (config: RequestConfig) => { + const properties = config.reqOpts!.mutations![0].upsert!.properties; + Object.keys(properties!).forEach(path => { + validateIndex(properties![path]); + }); + done(); + }; + + datastore.save( + { + key, + data, + excludeFromIndexes: [ + 'longString', + 'notMetadata', + 'longStringArray[]', + 'metadata.longString', + 'metadata.otherProperty', + 'metadata.obj.*', + 'metadata.longStringArray[].*', + ], + }, + assert.ifError, + ); + }); + + it('should allow setting the indexed value on arrays', done => { + datastore.request_ = (config: RequestConfig) => { + const property = + config.reqOpts!.mutations![0].upsert!.properties!.name; + + property.arrayValue!.values!.forEach((value: Any) => { + assert.strictEqual(value.excludeFromIndexes, true); + }); + + done(); + }; + + datastore.save( + { + key, + data: [ + { + name: 'name', + value: ['one', 'two', 'three'], + excludeFromIndexes: true, + }, + ], + }, + assert.ifError, + ); + }); + + it('should prepare excludeFromIndexes array for large values', done => { + const longString = Buffer.alloc(1501, '.').toString(); + const data = { + longString, + notMetadata: true, + longStringArray: [longString], + metadata: { + longString, + otherProperty: 'value', + obj: { + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + longStringArray: [ + { + longString, + nestedLongStringArray: [ + { + longString, + nestedProperty: true, + }, + { + longString, + }, + ], + }, + ], + }, + }; + + const excludeFromIndexes = [ + 'longString', + 'longStringArray[]', + 'metadata.longString', + 'metadata.obj.longStringArray[].longString', + 'metadata.obj.longStringArray[].nestedLongStringArray[].longString', + 'metadata.longStringArray[].longString', + 'metadata.longStringArray[].nestedLongStringArray[].longString', + ]; + + fakeEntity.entityToEntityProto = (entity: EntityObject) => { + return entity as unknown as EntityProto; + }; + datastore.request_ = (config: RequestConfig) => { + assert.strictEqual( + (config.reqOpts!.mutations![0].upsert! as Entity) + .excludeLargeProperties, + true, + ); + assert.deepStrictEqual( + (config.reqOpts!.mutations![0].upsert! as Entity) + .excludeFromIndexes, + excludeFromIndexes, + ); + done(); + }; + + datastore.save( + { + key, + data, + excludeLargeProperties: true, + }, + assert.ifError, + ); + }); + + it('should allow auto setting the indexed value of a property with excludeLargeProperties', done => { + const longString = Buffer.alloc(1501, '.').toString(); + const data = [ + { + name: 'name', + value: longString, + }, + { + name: 'description', + value: 'value', + }, + ]; + + datastore.request_ = (config: RequestConfig) => { + assert.deepStrictEqual( + config.reqOpts!.mutations![0].upsert!.properties!.name + .excludeFromIndexes, + true, + ); + done(); + }; + + datastore.save( + { + key, + data, + excludeLargeProperties: true, + }, + assert.ifError, + ); + }); + + it('should assign ID on keys without them', done => { + const incompleteKey = new entity.Key({path: ['Incomplete']}); + const incompleteKey2 = new entity.Key({path: ['Incomplete']}); + const completeKey = new entity.Key({path: ['Complete', 'Key']}); + + const keyProtos: Array<{}> = []; + const ids = [1, 2]; + + const response = { + mutationResults: [ + { + key: {}, + }, + { + key: {}, + }, + {}, + ], + }; + + datastore.request_ = (config: RequestConfig, callback: Function) => { + callback(null, response); + }; + + sandbox.stub(fakeEntity, 'keyFromKeyProto').callsFake(keyProto => { + keyProtos.push(keyProto as any); + return { + id: ids[keyProtos.length - 1], + } as {} as entity.Key; + }); + + datastore.save( + [ + {key: incompleteKey, data: {}}, + {key: incompleteKey2, data: {}}, + {key: completeKey, data: {}}, + ], + (err: Error) => { + assert.ifError(err); + + assert.strictEqual(incompleteKey.id, ids[0]); + assert.strictEqual(incompleteKey2.id, ids[1]); + + assert.strictEqual(keyProtos.length, 2); + assert.strictEqual(keyProtos[0], response.mutationResults[0].key); + assert.strictEqual(keyProtos[1], response.mutationResults[1].key); + + done(); + }, + ); + }); + + describe('transactions', () => { + beforeEach(() => { + // Trigger transaction mode. + datastore.id = 'transaction-id'; + datastore.requestCallbacks_ = []; + datastore.requests_ = []; + }); + + it('should queue request & callback', () => { + datastore.save({ + key, + data: [{name: 'name', value: 'value'}], + }); + + assert.strictEqual( + typeof datastore.requestCallbacks_[0], + 'function', + ); + assert.strictEqual(typeof datastore.requests_[0], 'object'); + }); + }); + }); + + describe('update', () => { + afterEach(() => { + sandbox.restore(); + }); + + it('should prepare entity objects', done => { + const entityObject = {}; + const preparedEntityObject = {prepared: true}; + const expectedEntityObject = Object.assign({}, preparedEntityObject, { + method: 'update', + }); + + sandbox + .stub(ds.DatastoreRequest, 'prepareEntityObject_') + .callsFake(obj => { + assert.strictEqual(obj, entityObject); + return preparedEntityObject as {}; + }); + + datastore.save = (entities: Entity[]) => { + assert.deepStrictEqual(entities[0], expectedEntityObject); + done(); + }; + + datastore.update(entityObject, assert.ifError); + }); + + it('should pass the correct arguments to save', done => { + datastore.save = (entities: Entity[], callback: Function) => { + assert.deepStrictEqual(JSON.parse(JSON.stringify(entities)), [ + { + key: { + namespace: 'ns', + kind: 'Company', + path: ['Company', null], + }, + data: {}, + method: 'update', + }, + ]); + callback(); + }; + + const key = new entity.Key({namespace: 'ns', path: ['Company']}); + datastore.update({key, data: {}}, done); + }); + }); + + describe('upsert', () => { + afterEach(() => { + sandbox.restore(); + }); + + it('should prepare entity objects', done => { + const entityObject = {}; + const preparedEntityObject = {prepared: true}; + const expectedEntityObject = Object.assign({}, preparedEntityObject, { + method: 'upsert', + }); + + sandbox + .stub(ds.DatastoreRequest, 'prepareEntityObject_') + .callsFake(obj => { + assert.strictEqual(obj, entityObject); + return preparedEntityObject as {}; + }); + + datastore.save = (entities: Entity[]) => { + assert.deepStrictEqual(entities[0], expectedEntityObject); + done(); + }; + + datastore.upsert(entityObject, assert.ifError); + }); + + it('should pass the correct arguments to save', done => { + datastore.save = (entities: Entity[], callback: Function) => { + assert.deepStrictEqual(JSON.parse(JSON.stringify(entities)), [ + { + key: { + namespace: 'ns', + kind: 'Company', + path: ['Company', null], + }, + data: {}, + method: 'upsert', + }, + ]); + + callback(); + }; + + const key = new entity.Key({namespace: 'ns', path: ['Company']}); + datastore.upsert({key, data: {}}, done); + }); + }); + + describe('transaction', () => { + it('should return a Transaction object', () => { + const transaction = datastore.transaction(); + assert.strictEqual(transaction.calledWith_[0], datastore); + }); + + it('should pass options to the Transaction constructor', () => { + const options = {}; + const transaction = datastore.transaction(options); + assert.strictEqual(transaction.calledWith_[1], options); + }); + }); + + describe('determineBaseUrl_', () => { + function setHost(host: string) { + process.env.DATASTORE_EMULATOR_HOST = host; + } + + beforeEach(() => { + delete process.env.DATASTORE_EMULATOR_HOST; + }); + + it('should default to defaultBaseUrl_', () => { + const defaultBaseUrl_ = 'defaulturl'; + datastore.defaultBaseUrl_ = defaultBaseUrl_; + + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.baseUrl_, defaultBaseUrl_); + }); + + it('should remove slashes from the baseUrl', () => { + const expectedBaseUrl = 'localhost'; + + setHost('localhost/'); + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.baseUrl_, expectedBaseUrl); + + setHost('localhost//'); + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.baseUrl_, expectedBaseUrl); + }); + + it('should remove the protocol if specified', () => { + setHost('http://localhost'); + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.baseUrl_, 'localhost'); + + setHost('https://localhost'); + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.baseUrl_, 'localhost'); + }); + + it('should set Numberified port if one was found', () => { + setHost('http://localhost:9090'); + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.port_, 9090); + }); + + it('should not set customEndpoint_ when using default baseurl', () => { + const datastore = new Datastore({projectId: PROJECT_ID}); + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.customEndpoint_, undefined); + }); + + it('should set customEndpoint_ when using custom API endpoint', () => { + datastore.determineBaseUrl_('apiEndpoint'); + assert.strictEqual(datastore.customEndpoint_, true); + }); + + it('should set baseUrl when using custom API endpoint', () => { + datastore.determineBaseUrl_('apiEndpoint'); + assert.strictEqual(datastore.baseUrl_, 'apiEndpoint'); + }); + + describe('with DATASTORE_EMULATOR_HOST environment variable', () => { + const DATASTORE_EMULATOR_HOST = 'localhost:9090'; + const EXPECTED_BASE_URL = 'localhost'; + const EXPECTED_PORT = 9090; + + beforeEach(() => { + setHost(DATASTORE_EMULATOR_HOST); + }); + + after(() => { + delete process.env.DATASTORE_EMULATOR_HOST; + }); + + it('should use the DATASTORE_EMULATOR_HOST env var', () => { + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.baseUrl_, EXPECTED_BASE_URL); + assert.strictEqual(datastore.port_, EXPECTED_PORT); + }); + + it('should set customEndpoint_', () => { + datastore.determineBaseUrl_(); + assert.strictEqual(datastore.customEndpoint_, true); + }); + }); + }); + + describe('keyToLegacyUrlSafe', () => { + it('should convert key to URL-safe base64 string', () => { + const key = new entity.Key({ + path: ['Task', 'Test'], + }); + const base64EndocdedUrlSafeKey = + 'agpwcm9qZWN0LWlkcg4LEgRUYXNrIgRUZXN0DA'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (datastore.auth as any).getProjectId = (callback: Function) => { + callback(null, 'project-id'); + }; + datastore.keyToLegacyUrlSafe( + key, + (err: Error | null | undefined, urlSafeKey: string) => { + assert.ifError(err); + assert.strictEqual(urlSafeKey, base64EndocdedUrlSafeKey); + }, + ); + }); + + it('should convert key to URL-safe base64 string with location prefix', () => { + const key = new entity.Key({ + path: ['Task', 'Test'], + }); + const locationPrefix = 's~'; + const base64EndocdedUrlSafeKey = + 'agxzfnByb2plY3QtaWRyDgsSBFRhc2siBFRlc3QM'; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (datastore.auth as any).getProjectId = (callback: Function) => { + callback(null, 'project-id'); + }; + datastore.keyToLegacyUrlSafe( + key, + locationPrefix, + (err: Error | null | undefined, urlSafeKey: string) => { + assert.ifError(err); + assert.strictEqual(urlSafeKey, base64EndocdedUrlSafeKey); + }, + ); + }); + + it('should not return URL-safe key to user if auth.getProjectId errors', () => { + const error = new Error('Error.'); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (datastore.auth as any).getProjectId = (callback: Function) => { + callback(error); + }; + datastore.keyToLegacyUrlSafe( + {} as entity.Key, + (err: Error | null | undefined, urlSafeKey: string) => { + assert.strictEqual(err, error); + assert.strictEqual(urlSafeKey, undefined); + }, + ); + }); + }); + + describe('keyFromLegacyUrlsafe', () => { + it('should convert key to url safe base64 string', () => { + const encodedKey = 'agpwcm9qZWN0LWlkcg4LEgRUYXNrIgRUZXN0DA'; + const key = datastore.keyFromLegacyUrlsafe(encodedKey); + assert.strictEqual(key.kind, 'Task'); + assert.strictEqual(key.name, 'Test'); + }); + }); + + describe('without using mocks', () => { + describe('on save tests', () => { + const onSaveTests = [ + { + description: + 'should encode a save request without excludeFromIndexes', + properties: {k: {stringValue: 'v'}}, + entitiesWithoutKey: {data: {k: 'v'}}, + }, + { + description: + 'should add exclude from indexes to property k and ignore excludeFromIndexes with wildcard', + properties: {k: {stringValue: 'v', excludeFromIndexes: true}}, + entitiesWithoutKey: { + data: {k: 'v'}, + excludeFromIndexes: ['k', 'k.*'], + }, + }, + { + description: + 'should encode a save request without properties and without excludeFromIndexes', + properties: {}, + entitiesWithoutKey: {data: {}}, + }, + { + description: + 'should encode a save request with no properties ignoring excludeFromIndexes for a property not on save data', + properties: {}, + entitiesWithoutKey: { + data: {}, + excludeFromIndexes: [ + 'non_exist_property', // this just ignored + 'non_exist_property.*', // should also be ignored + ], + }, + }, + { + description: + 'should encode a save request with one property ignoring excludeFromIndexes for a property not on save data', + properties: {k: {stringValue: 'v'}}, + entitiesWithoutKey: { + data: {k: 'v'}, + excludeFromIndexes: [ + 'non_exist_property[]', // this just ignored + ], + }, + }, + { + description: + 'should encode a save request with one property ignoring excludeFromIndexes for a property with a wildcard not on save data', + properties: {k: {stringValue: 'v'}}, + entitiesWithoutKey: { + data: {k: 'v'}, + excludeFromIndexes: [ + 'non_exist_property[].*', // this just ignored + ], + }, + }, + ]; + + async.each( + onSaveTests, + (onSaveTest: { + description: string; + properties: google.datastore.v1.IValue; + entitiesWithoutKey: Entities; + }) => { + it(`${onSaveTest.description}`, async () => { + const datastore = new OriginalDatastore({ + namespace: `${Date.now()}`, + }); + { + // This block of code mocks out request_ to check values passed into it. + const expectedConfig = { + client: 'DatastoreClient', + method: 'commit', + gaxOpts: {}, + reqOpts: { + mutations: [ + { + upsert: { + key: { + path: [{kind: 'Post', name: 'Post1'}], + partitionId: { + namespaceId: datastore.namespace, + }, + }, + properties: onSaveTest.properties, + }, + }, + ], + }, + }; + // Mock out the request function to compare config passed into it. + datastore.request_ = ( + config: RequestConfig, + callback: RequestCallback, + ) => { + try { + assert.deepStrictEqual(config, expectedConfig); + callback(null, 'some-data'); + } catch (e: any) { + callback(e); + } + }; + } + { + // Attach key to entities parameter passed in and run save with those parameters. + const key = datastore.key(['Post', 'Post1']); + const entities = Object.assign( + {key}, + onSaveTest.entitiesWithoutKey, + ); + const results = await datastore.save(entities); + assert.deepStrictEqual(results, ['some-data']); + } + }); + }, + ); + }); + }); + + describe('multi-db support', () => { + it('should get the database id from the client', async () => { + const otherDatastore = new Datastore({ + namespace: `${Date.now()}`, + databaseId: SECOND_DATABASE_ID, + }); + assert.strictEqual( + otherDatastore.getDatabaseId(), + SECOND_DATABASE_ID, + ); + }); + }); + + describe('Query Profiling', () => { + const executionStats = { + resultsReturned: '8', + executionDuration: { + seconds: '0', + nanos: 95389000, + }, + readOperations: '8', + debugStats: { + fields: { + index_entries_scanned: { + stringValue: '8', + kind: 'stringValue', + }, + documents_scanned: { + stringValue: '8', + kind: 'stringValue', + }, + }, + }, + }; + const planSummary = { + indexesUsed: [ + { + fields: { + query_scope: { + stringValue: 'Collection Group', + kind: 'stringValue', + }, + properties: { + stringValue: '(__name__ASC)', + kind: 'stringValue', + }, + }, + }, + ], + }; + const expectedPlanSummary = { + indexesUsed: [ + { + query_scope: 'Collection Group', + properties: '(__name__ASC)', + }, + ], + }; + const expectedExecutionStats = { + resultsReturned: 8, + readOperations: 8, + executionDuration: { + seconds: '0', + nanos: 95389000, + }, + debugStats: { + index_entries_scanned: '8', + documents_scanned: '8', + }, + }; + // mode string, mode enum type, explainMetrics, expectedInfo + async.each( + [ + { + modeName: 'ExplainAnalyze', + options: { + explainOptions: { + analyze: true, + }, + }, + expectedInfo: { + explainMetrics: { + planSummary: expectedPlanSummary, + executionStats: expectedExecutionStats, + }, + }, + explainMetrics: { + explainMetrics: { + executionStats, + planSummary, + }, + }, + expectedExplainOptions: { + analyze: true, + }, + }, + { + modeName: 'Explain', + options: { + explainOptions: { + analyze: false, + }, + }, + expectedInfo: { + explainMetrics: { + planSummary: expectedPlanSummary, + }, + }, + explainMetrics: { + explainMetrics: { + planSummary, + }, + }, + expectedExplainOptions: { + analyze: false, + }, + }, + { + modeName: 'Normal', + options: {}, + expectedInfo: {}, + explainMetrics: {}, + expectedExplainOptions: undefined, + }, + ], + (modeOptions: { + modeName: string; + options: { + explainOptions?: ExplainOptions; + }; + explainMetrics: ExplainMetrics; + expectedInfo: RunQueryInfo; + expectedExplainOptions: ExplainOptions; + }) => { + const datastore = new ds.Datastore(); + describe(`for the ${modeOptions.modeName} query mode`, () => { + it('should provide correct request/response data for runQuery', async () => { + // Mock out the request function to compare config passed into it. + datastore.request_ = ( + config: RequestConfig, + callback: RequestCallback, + ) => { + assert.deepStrictEqual(config.client, 'DatastoreClient'); + assert.deepStrictEqual(config.method, 'runQuery'); + assert.deepStrictEqual( + config.reqOpts?.explainOptions, + modeOptions.expectedExplainOptions, + ); + callback( + null, + Object.assign( + { + batch: { + entityResults: [], + moreResults: 'NO_MORE_RESULTS', + }, + }, + modeOptions.explainMetrics, + ), + ); + }; + const ancestor = datastore.key(['Book', 'GoT']); + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor); + const [entities, info] = await datastore.runQuery( + q, + modeOptions.options, + ); + assert.deepStrictEqual(entities, []); + assert.deepStrictEqual( + info, + Object.assign( + {moreResults: 'NO_MORE_RESULTS'}, + modeOptions.expectedInfo, + ), + ); + }); + it('should provide correct request/response data for runAggregationQuery', async () => { + // Mock out the request function to compare config passed into it. + datastore.request_ = ( + config: RequestConfig, + callback: RequestCallback, + ) => { + assert.deepStrictEqual(config.client, 'DatastoreClient'); + assert.deepStrictEqual(config.method, 'runAggregationQuery'); + assert.deepStrictEqual( + config.reqOpts?.explainOptions, + modeOptions.expectedExplainOptions, + ); + callback( + null, + Object.assign( + { + batch: { + aggregationResults: [], + moreResults: 'NO_MORE_RESULTS', + }, + }, + modeOptions.explainMetrics, + ), + ); + }; + const ancestor = datastore.key(['Book', 'GoT']); + const q = datastore + .createQuery('Character') + .hasAncestor(ancestor); + const aggregate = datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.sum('appearances')); + const [entities, info] = await datastore.runAggregationQuery( + aggregate, + modeOptions.options, + ); + assert.deepStrictEqual(entities, []); + assert.deepStrictEqual(info, modeOptions.expectedInfo); + }); + }); + }, + ); + }); + }); + }, +); diff --git a/handwritten/nodejs-datastore/test/query.ts b/handwritten/nodejs-datastore/test/query.ts new file mode 100644 index 00000000000..7238a443342 --- /dev/null +++ b/handwritten/nodejs-datastore/test/query.ts @@ -0,0 +1,626 @@ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as assert from 'assert'; +import {beforeEach, describe, it} from 'mocha'; +// eslint-disable-next-line @typescript-eslint/no-var-requires +const {Query} = require('../src/query'); +// eslint-disable-next-line @typescript-eslint/no-var-requires +import {Datastore} from '../src'; +import {AggregateField, AggregateQuery} from '../src/aggregate'; +import {PropertyFilter, EntityFilter, or} from '../src/filter'; +import {entity} from '../src/entity'; +import {SECOND_DATABASE_ID} from './index'; + +describe('Query', () => { + const SCOPE = {} as Datastore; + const NAMESPACE = 'Namespace'; + const KINDS = ['Kind']; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + let query: any; + + beforeEach(() => { + query = new Query(SCOPE, NAMESPACE, KINDS); + }); + + describe('instantiation', () => { + it('should localize the scope', () => { + assert.strictEqual(query.scope, SCOPE); + }); + + it('should localize the namespace', () => { + assert.strictEqual(query.namespace, NAMESPACE); + }); + + it('should localize the kind', () => { + assert.strictEqual(query.kinds, KINDS); + }); + + it('should use null for all falsy namespace values', () => { + [ + new Query(SCOPE, '', KINDS), + new Query(SCOPE, null, KINDS), + new Query(SCOPE, undefined, KINDS), + new Query(SCOPE, 0 as {} as string, KINDS), + new Query(SCOPE, KINDS), + ].forEach(query => { + assert.strictEqual(query.namespace, null); + }); + }); + + describe('Aggregation queries', () => { + it('should create a query with a count aggregation', () => { + const query = new Query(['kind1']); + const firstAggregation = AggregateField.count().alias('total'); + const secondAggregation = AggregateField.count().alias('total2'); + const aggregate = new AggregateQuery(query).addAggregations([ + firstAggregation, + secondAggregation, + ]); + const aggregate2 = new AggregateQuery(query) + .count('total') + .count('total2'); + assert.deepStrictEqual(aggregate.aggregations, aggregate2.aggregations); + assert.deepStrictEqual(aggregate.aggregations, [ + firstAggregation, + secondAggregation, + ]); + }); + + describe('AggregateField toProto', () => { + it('should produce the right proto with a count aggregation', () => { + assert.deepStrictEqual( + AggregateField.count().alias('alias1').toProto(), + { + alias: 'alias1', + count: {}, + }, + ); + }); + it('should produce the right proto with a sum aggregation', () => { + assert.deepStrictEqual( + AggregateField.sum('property1').alias('alias1').toProto(), + { + alias: 'alias1', + operator: 'sum', + sum: { + property: { + name: 'property1', + }, + }, + }, + ); + }); + it('should produce the right proto with an average aggregation', () => { + assert.deepStrictEqual( + AggregateField.average('property1').alias('alias1').toProto(), + { + alias: 'alias1', + avg: { + property: { + name: 'property1', + }, + }, + operator: 'avg', + }, + ); + }); + }); + + describe('comparing equivalent aggregation queries', async () => { + function generateAggregateQuery() { + return new AggregateQuery(new Query(['kind1'])); + } + + function compareAggregations( + aggregateQuery: AggregateQuery, + aggregateFields: AggregateField[], + ) { + const addAggregationsAggregate = generateAggregateQuery(); + addAggregationsAggregate.addAggregations(aggregateFields); + const addAggregationAggregate = generateAggregateQuery(); + aggregateFields.forEach(aggregateField => + addAggregationAggregate.addAggregation(aggregateField), + ); + assert.deepStrictEqual( + aggregateQuery.aggregations, + addAggregationsAggregate.aggregations, + ); + assert.deepStrictEqual( + aggregateQuery.aggregations, + addAggregationAggregate.aggregations, + ); + assert.deepStrictEqual(aggregateQuery.aggregations, aggregateFields); + } + describe('comparing aggregations with an alias', async () => { + it('should compare equivalent count aggregation queries', () => { + compareAggregations( + generateAggregateQuery().count('total1').count('total2'), + ['total1', 'total2'].map(alias => + AggregateField.count().alias(alias), + ), + ); + }); + it('should compare equivalent sum aggregation queries', () => { + compareAggregations( + generateAggregateQuery() + .sum('property1', 'alias1') + .sum('property2', 'alias2'), + [ + AggregateField.sum('property1').alias('alias1'), + AggregateField.sum('property2').alias('alias2'), + ], + ); + }); + it('should compare equivalent average aggregation queries', () => { + compareAggregations( + generateAggregateQuery() + .average('property1', 'alias1') + .average('property2', 'alias2'), + [ + AggregateField.average('property1').alias('alias1'), + AggregateField.average('property2').alias('alias2'), + ], + ); + }); + }); + describe('comparing aggregations without an alias', async () => { + it('should compare equivalent count aggregation queries', () => { + compareAggregations( + generateAggregateQuery().count().count(), + ['total1', 'total2'].map(() => AggregateField.count()), + ); + }); + it('should compare equivalent sum aggregation queries', () => { + compareAggregations( + generateAggregateQuery().sum('property1').sum('property2'), + [ + AggregateField.sum('property1'), + AggregateField.sum('property2'), + ], + ); + }); + it('should compare equivalent average aggregation queries', () => { + compareAggregations( + generateAggregateQuery() + .average('property1') + .average('property2'), + [ + AggregateField.average('property1'), + AggregateField.average('property2'), + ], + ); + }); + }); + }); + }); + }); + + describe('filter', () => { + it('should issue a warning when a Filter instance is not provided', done => { + const onWarning = (warning: {message: unknown}) => { + assert.strictEqual( + warning.message, + 'Providing Filter objects like Composite Filter or Property Filter is recommended when using .filter', + ); + process.removeListener('warning', onWarning); + done(); + }; + process.on('warning', onWarning); + new Query(['kind1']).filter('name', 'Stephen'); + }); + it('should not issue a warning again when a Filter instance is not provided', done => { + const onWarning = () => { + assert.fail(); + }; + process.on('warning', onWarning); + new Query(['kind1']).filter('name', 'Stephen'); + setImmediate(() => { + process.removeListener('warning', onWarning); + done(); + }); + }); + it('should support filtering', () => { + const now = new Date(); + const query = new Query(['kind1']).filter('date', '<=', now); + const filter = query.filters[0]; + + assert.strictEqual(filter.name, 'date'); + assert.strictEqual(filter.op, '<='); + assert.strictEqual(filter.val, now); + }); + + it('should recognize all the different operators', () => { + const now = new Date(); + const query = new Query(['kind1']) + .filter('date', '<=', now) + .filter('name', '=', 'Title') + .filter('count', '>', 20) + .filter('size', '<', 10) + .filter('something', '>=', 11) + .filter('neProperty', '!=', 12) + .filter('inProperty', 'IN', 13) + .filter('notInProperty', 'NOT_IN', 14); + + assert.strictEqual(query.filters[0].name, 'date'); + assert.strictEqual(query.filters[0].op, '<='); + assert.strictEqual(query.filters[0].val, now); + + assert.strictEqual(query.filters[1].name, 'name'); + assert.strictEqual(query.filters[1].op, '='); + assert.strictEqual(query.filters[1].val, 'Title'); + + assert.strictEqual(query.filters[2].name, 'count'); + assert.strictEqual(query.filters[2].op, '>'); + assert.strictEqual(query.filters[2].val, 20); + + assert.strictEqual(query.filters[3].name, 'size'); + assert.strictEqual(query.filters[3].op, '<'); + assert.strictEqual(query.filters[3].val, 10); + + assert.strictEqual(query.filters[4].name, 'something'); + assert.strictEqual(query.filters[4].op, '>='); + assert.strictEqual(query.filters[4].val, 11); + + assert.strictEqual(query.filters[5].name, 'neProperty'); + assert.strictEqual(query.filters[5].op, '!='); + assert.strictEqual(query.filters[5].val, 12); + + assert.strictEqual(query.filters[6].name, 'inProperty'); + assert.strictEqual(query.filters[6].op, 'IN'); + assert.strictEqual(query.filters[6].val, 13); + + assert.strictEqual(query.filters[7].name, 'notInProperty'); + assert.strictEqual(query.filters[7].op, 'NOT_IN'); + assert.strictEqual(query.filters[7].val, 14); + }); + + it('should remove any whitespace surrounding the filter name', () => { + const query = new Query(['kind1']).filter(' count ', '>', 123); + + assert.strictEqual(query.filters[0].name, 'count'); + }); + + it('should remove any whitespace surrounding the operator', () => { + const query = new Query(['kind1']).filter( + 'count', + ' < ', + 123, + ); + + assert.strictEqual(query.filters[0].op, '<'); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.filter('count', '<', 5); + + assert.strictEqual(query, nextQuery); + }); + + it('should default the operator to "="', () => { + const query = new Query(['kind1']).filter('name', 'Stephen'); + const filter = query.filters[0]; + + assert.strictEqual(filter.name, 'name'); + assert.strictEqual(filter.op, '='); + assert.strictEqual(filter.val, 'Stephen'); + }); + }); + it('should not issue a warning when an EntityFilter instance is provided', done => { + const onWarning = () => { + assert.fail(); + }; + process.on('warning', onWarning); + new Query(['kind1']).filter(new PropertyFilter('name', '=', 'Stephen')); + setImmediate(() => { + process.removeListener('warning', onWarning); + done(); + }); + }); + describe('filter with Filter class', () => { + it('should support filter with Filter', () => { + const now = new Date(); + const query = new Query(['kind1']).filter( + new PropertyFilter('date', '<=', now), + ); + const filter = query.entityFilters[0]; + + assert.strictEqual(filter.name, 'date'); + assert.strictEqual(filter.op, '<='); + assert.strictEqual(filter.val, now); + }); + it('should support filter with OR', () => { + const now = new Date(); + const query = new Query(['kind1']).filter( + or([ + new PropertyFilter('date', '<=', now), + new PropertyFilter('name', '=', 'Stephen'), + ]), + ); + const filter = query.entityFilters[0]; + assert.strictEqual(filter.op, 'OR'); + // Check filters + const filters = filter.filters; + assert.strictEqual(filters.length, 2); + assert.strictEqual(filters[0].name, 'date'); + assert.strictEqual(filters[0].op, '<='); + assert.strictEqual(filters[0].val, now); + assert.strictEqual(filters[1].name, 'name'); + assert.strictEqual(filters[1].op, '='); + assert.strictEqual(filters[1].val, 'Stephen'); + }); + it('should accept null as value', () => { + assert.strictEqual( + new Query(['kind1']).filter('status', null).filters.pop()?.val, + null, + ); + assert.strictEqual( + new Query(['kind1']).filter('status', '=', null).filters.pop()?.val, + null, + ); + }); + }); + + describe('hasAncestor', () => { + it('should support ancestor filtering', () => { + const query = new Query(['kind1']).hasAncestor(['kind2', 123]); + + assert.strictEqual(query.filters[0].name, '__key__'); + assert.strictEqual(query.filters[0].op, 'HAS_ANCESTOR'); + assert.deepStrictEqual(query.filters[0].val, ['kind2', 123]); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.hasAncestor(['kind2', 123]); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('order', () => { + it('should default ordering to ascending', () => { + const query = new Query(['kind1']).order('name'); + + assert.strictEqual(query.orders[0].name, 'name'); + assert.strictEqual(query.orders[0].sign, '+'); + }); + + it('should support ascending order', () => { + const query = new Query(['kind1']).order('name'); + + assert.strictEqual(query.orders[0].name, 'name'); + assert.strictEqual(query.orders[0].sign, '+'); + }); + + it('should support descending order', () => { + const query = new Query(['kind1']).order('count', {descending: true}); + + assert.strictEqual(query.orders[0].name, 'count'); + assert.strictEqual(query.orders[0].sign, '-'); + }); + + it('should support both ascending and descending', () => { + const query = new Query(['kind1']) + .order('name') + .order('count', {descending: true}); + + assert.strictEqual(query.orders[0].name, 'name'); + assert.strictEqual(query.orders[0].sign, '+'); + assert.strictEqual(query.orders[1].name, 'count'); + assert.strictEqual(query.orders[1].sign, '-'); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.order('name'); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('groupBy', () => { + it('should store an array of properties to group by', () => { + const query = new Query(['kind1']).groupBy(['name', 'size']); + + assert.deepStrictEqual(query.groupByVal, ['name', 'size']); + }); + + it('should convert a single property into an array', () => { + const query = new Query(['kind1']).groupBy('name'); + + assert.deepStrictEqual(query.groupByVal, ['name']); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.groupBy(['name', 'size']); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('select', () => { + it('should store an array of properties to select', () => { + const query = new Query(['kind1']).select(['name', 'size']); + + assert.deepStrictEqual(query.selectVal, ['name', 'size']); + }); + + it('should convert a single property into an array', () => { + const query = new Query(['kind1']).select('name'); + + assert.deepStrictEqual(query.selectVal, ['name']); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.select(['name', 'size']); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('start', () => { + it('should capture the starting cursor value', () => { + const query = new Query(['kind1']).start('X'); + + assert.strictEqual(query.startVal, 'X'); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.start('X'); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('end', () => { + it('should capture the ending cursor value', () => { + const query = new Query(['kind1']).end('Z'); + + assert.strictEqual(query.endVal, 'Z'); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.end('Z'); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('limit', () => { + it('should capture the number of results to limit to', () => { + const query = new Query(['kind1']).limit(20); + + assert.strictEqual(query.limitVal, 20); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.limit(20); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('offset', () => { + it('should capture the number of results to offset by', () => { + const query = new Query(['kind1']).offset(100); + + assert.strictEqual(query.offsetVal, 100); + }); + + it('should return the query instance', () => { + const query = new Query(['kind1']); + const nextQuery = query.offset(100); + + assert.strictEqual(query, nextQuery); + }); + }); + + describe('run', () => { + it('should call the parent instance runQuery correctly', done => { + const args = [{}, () => {}]; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + query.scope.runQuery = function (...thisArgs: any[]) { + assert.strictEqual(this, query.scope); + assert.strictEqual(thisArgs[0], query); + assert.strictEqual(thisArgs[1], args[0]); + done(); + }; + + query.run(...args); + }); + }); + + describe('runStream', () => { + it('should not require options', () => { + const runQueryReturnValue = {}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + query.scope.runQueryStream = function (...args: any[]) { + assert.strictEqual(this, query.scope); + assert.strictEqual(args[0], query); + return runQueryReturnValue; + }; + + const results = query.runStream(); + assert.strictEqual(results, runQueryReturnValue); + }); + + it('should call the parent instance runQueryStream correctly', () => { + const options = { + consistency: 'string', + gaxOptions: {}, + wrapNumbers: true, + }; + const runQueryReturnValue = {}; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + query.scope.runQueryStream = function (...args: any[]) { + assert.strictEqual(this, query.scope); + assert.strictEqual(args[0], query); + assert.strictEqual(args[1], options); + return runQueryReturnValue; + }; + + const results = query.runStream(options); + assert.strictEqual(results, runQueryReturnValue); + }); + }); + + it('should pass the database id to the generated layer', async () => { + const options = { + namespace: `${Date.now()}`, + databaseId: SECOND_DATABASE_ID, + projectId: 'test-project-id', + }; + const clientName = 'DatastoreClient'; + const otherDatastore = new Datastore(options); + const postKey = new entity.Key({path: ['Post', 'post1']}); + // Initialize the generated client so that we can mock it out + const gapic = Object.freeze({ + v1: require('../src/v1'), + }); + otherDatastore.clients_.set(clientName, new gapic.v1[clientName](options)); + const dataClient = otherDatastore.clients_.get(clientName); + const projectId = await otherDatastore.getProjectId(); + if (dataClient) { + dataClient['commit'] = ( + request: any, + options: any, + callback: (err?: unknown) => void, + ) => { + try { + assert.strictEqual(request.databaseId, SECOND_DATABASE_ID); + assert.strictEqual(request.projectId, projectId); + assert.strictEqual( + options.headers['google-cloud-resource-prefix'], + `projects/${projectId}`, + ); + } catch (e) { + callback(e); + } + callback(); + }; + } + await otherDatastore.save({key: postKey, data: {title: 'test'}}); + }); +}); diff --git a/handwritten/nodejs-datastore/test/request.ts b/handwritten/nodejs-datastore/test/request.ts new file mode 100644 index 00000000000..48f582381a1 --- /dev/null +++ b/handwritten/nodejs-datastore/test/request.ts @@ -0,0 +1,1953 @@ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as pfy from '@google-cloud/promisify'; +import * as assert from 'assert'; +import {after, afterEach, before, beforeEach, describe, it} from 'mocha'; +import * as extend from 'extend'; +import * as gax from 'google-gax'; +import * as is from 'is'; +import * as proxyquire from 'proxyquire'; +import * as sinon from 'sinon'; +import {PassThrough, Transform} from 'stream'; + +import {google} from '../protos/protos'; +import * as ds from '../src'; +import {entity, Entity, KeyProto} from '../src/entity.js'; +import {IntegerTypeCastOptions, Query, QueryProto} from '../src/query.js'; +import {outOfBoundsError} from './entity'; +import { + AllocateIdsResponse, + RequestConfig, + RequestOptions, + PrepareEntityObjectResponse, + CommitResponse, + GetResponse, + RequestCallback, +} from '../src/request'; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type Any = any; + +let promisified = false; +const fakePfy = Object.assign({}, pfy, { + promisifyAll(klass: Function) { + if (klass.name === 'DatastoreRequest') { + promisified = true; + } + }, +}); + +let v1FakeClientOverride: Function | null; +const fakeV1 = { + FakeClient: class { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + constructor(...args: any[]) { + return (v1FakeClientOverride || (() => {}))(...args); + } + }, +}; + +class FakeQuery extends Query {} + +describe('Request', () => { + let Request: typeof ds.DatastoreRequest; + let request: Any; + let key: entity.Key; + const sandbox = sinon.createSandbox(); + + before(() => { + Request = proxyquire('../src/request', { + '@google-cloud/promisify': fakePfy, + './entity': {entity}, + './query': {Query: FakeQuery}, + './v1': fakeV1, + }).DatastoreRequest; + }); + + after(() => { + v1FakeClientOverride = null; + }); + + beforeEach(() => { + key = new entity.Key({ + namespace: 'namespace', + path: ['Company', 123], + }); + v1FakeClientOverride = null; + request = new Request(); + }); + + afterEach(() => sandbox.restore()); + + describe('instantiation', () => { + it('should promisify all the things', () => { + assert(promisified); + }); + }); + + describe('prepareEntityObject_', () => { + it('should clone an object', () => { + const obj = { + data: { + nested: { + obj: true, + }, + }, + method: 'insert', + }; + const expectedPreparedEntityObject = extend(true, {}, obj); + const preparedEntityObject = Request.prepareEntityObject_(obj) as Any; + assert.notStrictEqual(preparedEntityObject, obj); + assert.notStrictEqual(preparedEntityObject.data.nested, obj.data.nested); + assert.deepStrictEqual( + preparedEntityObject, + expectedPreparedEntityObject, + ); + }); + + it('should format an entity', () => { + const key = {}; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const entityObject: any = {data: true}; + entityObject[entity.KEY_SYMBOL] = key; + const preparedEntityObject = Request.prepareEntityObject_( + entityObject, + ) as Any; + assert.strictEqual(preparedEntityObject.key, key); + assert.strictEqual(preparedEntityObject.data.data, entityObject.data); + }); + }); + + describe('allocateIds', () => { + const INCOMPLETE_KEY = {} as entity.Key; + const ALLOCATIONS = 2; + const OPTIONS = { + allocations: ALLOCATIONS, + }; + + it('should throw if the key is complete', () => { + sandbox.stub(entity, 'keyToKeyProto'); + sandbox.stub(entity, 'isKeyComplete').callsFake(key => { + assert.strictEqual(key, INCOMPLETE_KEY); + return true; + }); + + assert.throws(() => { + request.allocateIds(INCOMPLETE_KEY, OPTIONS, assert.ifError); + }, new RegExp('An incomplete key should be provided.')); + }); + + it('should make the correct request', done => { + const keyProto = {} as KeyProto; + sandbox.stub(entity, 'isKeyComplete'); + sandbox.stub(entity, 'keyToKeyProto').callsFake(key => { + assert.strictEqual(key, INCOMPLETE_KEY); + return keyProto; + }); + + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'allocateIds'); + + const expectedKeys: Array<{}> = []; + expectedKeys.length = ALLOCATIONS; + expectedKeys.fill(keyProto); + assert.deepStrictEqual(config.reqOpts!.keys, expectedKeys); + assert.strictEqual(config.gaxOpts, undefined); + done(); + }; + + request.allocateIds(INCOMPLETE_KEY, OPTIONS, assert.ifError); + }); + + it('should allow a numeric shorthand for allocations', done => { + sandbox.stub(entity, 'isKeyComplete'); + sandbox.stub(entity, 'keyToKeyProto'); + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.reqOpts!.keys.length, ALLOCATIONS); + done(); + }; + request.allocateIds(INCOMPLETE_KEY, ALLOCATIONS, assert.ifError); + }); + + it('should allow customization of GAX options', done => { + sandbox.stub(entity, 'isKeyComplete'); + sandbox.stub(entity, 'keyToKeyProto'); + const options = Object.assign({}, OPTIONS, { + gaxOptions: {}, + }); + + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.gaxOpts, options.gaxOptions); + done(); + }; + + request.allocateIds(INCOMPLETE_KEY, options, assert.ifError); + }); + + describe('error', () => { + const ERROR = new Error('Error.'); + const API_RESPONSE = {}; + + beforeEach(() => { + request.request_ = (_: object, callback: Function) => { + callback(ERROR, API_RESPONSE); + }; + }); + + it('should exec callback with error & API response', done => { + sandbox.stub(entity, 'isKeyComplete'); + sandbox.stub(entity, 'keyToKeyProto'); + request.allocateIds( + INCOMPLETE_KEY, + OPTIONS, + (err: Error, keys: null, resp: {}) => { + assert.strictEqual(err, ERROR); + assert.strictEqual(keys, null); + assert.strictEqual(resp, API_RESPONSE); + done(); + }, + ); + }); + }); + + describe('success', () => { + const KEY = {}; + const API_RESPONSE = { + keys: [KEY], + }; + + beforeEach(() => { + request.request_ = (_: object, callback: Function) => { + callback(null!, API_RESPONSE); + }; + }); + + it('should create and return Keys & API response', done => { + const key = {} as entity.Key; + sandbox.stub(entity, 'isKeyComplete'); + sandbox.stub(entity, 'keyToKeyProto'); + sandbox.stub(entity, 'keyFromKeyProto').callsFake(keyProto => { + assert.strictEqual(keyProto, API_RESPONSE.keys[0]); + return key; + }); + request.allocateIds( + INCOMPLETE_KEY, + OPTIONS, + (err: Error, keys: entity.Key[], resp: AllocateIdsResponse) => { + assert.ifError(err); + assert.deepStrictEqual(keys, [key]); + assert.strictEqual(resp, API_RESPONSE); + done(); + }, + ); + }); + }); + }); + + describe('createReadStream', () => { + beforeEach(() => { + request.request_ = () => {}; + }); + + it('should throw if no keys are provided', () => { + assert.throws(() => { + request.createReadStream(null!); + }, /At least one Key object is required/); + }); + + it('should convert key to key proto', done => { + sandbox.stub(entity, 'keyToKeyProto').callsFake(key_ => { + assert.strictEqual(key_, key); + done(); + return {} as KeyProto; + }); + + request.createReadStream(key).on('error', done); + }); + + it('should make correct request when stream is ready', done => { + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'lookup'); + assert.deepStrictEqual( + config.reqOpts!.keys[0], + entity.keyToKeyProto(key), + ); + done(); + }; + const stream = request.createReadStream(key); + stream.emit('reading'); + }); + + it('should allow customization of GAX options', done => { + const options = { + gaxOptions: {}, + }; + + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.gaxOpts, options.gaxOptions); + done(); + }; + + request.createReadStream(key, options).on('error', done).emit('reading'); + }); + + it('should allow setting strong read consistency', done => { + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.reqOpts!.readOptions!.readConsistency, 1); + done(); + }; + + request + .createReadStream(key, {consistency: 'strong'}) + .on('error', done) + .emit('reading'); + }); + + it('should allow setting strong eventual consistency', done => { + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.reqOpts!.readOptions!.readConsistency, 2); + done(); + }; + + request + .createReadStream(key, {consistency: 'eventual'}) + .on('error', done) + .emit('reading'); + }); + + describe('error', () => { + const error = new Error('Error.'); + const apiResponse = {a: 'b', c: 'd'}; + + beforeEach(() => { + request.request_ = (_: object, callback: Function) => { + setImmediate(() => { + callback(error, apiResponse); + }); + }; + }); + + it('should emit error', done => { + request + .createReadStream(key) + .on('data', () => {}) + .on('error', (err: Error) => { + assert.strictEqual(err, error); + done(); + }); + }); + + it('should end stream', done => { + const stream = request.createReadStream(key); + stream + .on('data', () => {}) + .on('error', () => { + setImmediate(() => { + assert.strictEqual(stream.destroyed, true); + done(); + }); + }); + }); + + it('should emit an error from results decoding', done => { + const largeInt = '922337203685477850'; + const propertyName = 'points'; + request.request_ = (config: RequestConfig, callback: Function) => { + callback(null, { + found: [ + { + entity: { + properties: { + [propertyName]: { + integerValue: largeInt, + valueType: 'integerValue', + }, + }, + }, + }, + ], + }); + }; + + const stream = request.createReadStream(key); + + stream + .on('data', () => {}) + .on('error', (err: Error) => { + assert.deepStrictEqual( + err, + outOfBoundsError({integerValue: largeInt, propertyName}), + ); + setImmediate(() => { + assert.strictEqual(stream.destroyed, true); + done(); + }); + }); + }); + }); + + describe('success', () => { + const apiResponse = { + found: [ + { + entity: { + key: { + partitionId: { + projectId: 'grape-spaceship-123', + }, + path: [ + { + kind: 'Post', + name: 'post1', + }, + ], + }, + properties: { + title: { + stringValue: 'How to make the perfect pizza in your grill', + }, + tags: { + arrayValue: { + values: [ + { + stringValue: 'pizza', + }, + { + stringValue: 'grill', + }, + ], + }, + }, + rating: { + integerValue: '5', + }, + author: { + stringValue: 'Silvano', + }, + wordCount: { + integerValue: '400', + }, + isDraft: { + booleanValue: false, + }, + }, + }, + }, + ], + }; + + const expectedResult = entity.formatArray(apiResponse.found as Any)[0]; + + const apiResponseWithMultiEntities = extend(true, {}, apiResponse); + const entities = apiResponseWithMultiEntities.found; + entities.push(entities[0]); + + const apiResponseWithDeferred = extend(true, {}, apiResponse) as Any; + apiResponseWithDeferred.deferred = [ + apiResponseWithDeferred.found[0].entity.key, + ]; + + beforeEach(() => { + request.request_ = (_: object, callback: Function) => { + callback(null!, apiResponse); + }; + }); + + it('should format the results', done => { + sandbox.stub(entity, 'formatArray').callsFake(arr => { + assert.strictEqual(arr, apiResponse.found); + setImmediate(done); + return arr; + }); + + request.createReadStream(key).on('error', done).emit('reading'); + }); + + describe('should pass `wrapNumbers` to formatArray', () => { + let wrapNumbersOpts: boolean | IntegerTypeCastOptions | undefined; + let formtArrayStub: Any; + + beforeEach(() => { + formtArrayStub = sandbox + .stub(entity, 'formatArray') + .callsFake(arr => { + assert.strictEqual(arr, apiResponse.found); + return arr; + }); + }); + + afterEach(() => { + formtArrayStub.restore(); + }); + + it('should pass `wrapNumbers` to formatArray as undefined by default', done => { + request.createReadStream(key).on('error', done).resume(); + + setImmediate(() => { + wrapNumbersOpts = formtArrayStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbersOpts, undefined); + done(); + }); + }); + + it('should pass `wrapNumbers` to formatArray as bolean', done => { + request + .createReadStream(key, {wrapNumbers: true}) + .on('error', done) + .resume(); + + setImmediate(() => { + wrapNumbersOpts = formtArrayStub.getCall(0).args[1]; + assert.strictEqual(typeof wrapNumbersOpts, 'boolean'); + done(); + }); + }); + + it('should pass `wrapNumbers` to formatArray as IntegerTypeCastOptions', done => { + const integerTypeCastOptions = { + integerTypeCastFunction: () => {}, + properties: 'that', + }; + + request + .createReadStream(key, {wrapNumbers: integerTypeCastOptions}) + .on('error', done) + .resume(); + + setImmediate(() => { + wrapNumbersOpts = formtArrayStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbersOpts, integerTypeCastOptions); + assert.deepStrictEqual(wrapNumbersOpts, integerTypeCastOptions); + done(); + }); + }); + }); + + it('should continue looking for deferred results', done => { + let numTimesCalled = 0; + + request.request_ = (config: RequestConfig, callback: Function) => { + numTimesCalled++; + + if (numTimesCalled === 1) { + callback(null!, apiResponseWithDeferred); + return; + } + + const expectedKeys = apiResponseWithDeferred.deferred + .map(entity.keyFromKeyProto) + .map(entity.keyToKeyProto); + + assert.deepStrictEqual(config.reqOpts!.keys, expectedKeys); + done(); + }; + + request.createReadStream(key).on('error', done).emit('reading'); + }); + + it('should push results to the stream', done => { + request + .createReadStream(key) + .on('error', done) + .on('data', (entity: Entity) => { + assert.deepStrictEqual(entity, expectedResult); + }) + .on('end', done) + .emit('reading'); + }); + + it('should not push more results if stream was ended', done => { + let entitiesEmitted = 0; + + request.request_ = (config: RequestConfig, callback: Function) => { + setImmediate(() => { + callback(null!, apiResponseWithMultiEntities); + }); + }; + + const stream = request.createReadStream([key, key]); + stream + .on('data', () => { + entitiesEmitted++; + stream.end(); + }) + .on('end', () => { + assert.strictEqual(entitiesEmitted, 1); + done(); + }) + .emit('reading'); + }); + + it('should not get more results if stream was ended', done => { + let lookupCount = 0; + + request.request_ = (config: RequestConfig, callback: Function) => { + lookupCount++; + setImmediate(() => { + callback(null!, apiResponseWithDeferred); + }); + }; + + const stream = request.createReadStream(key); + stream + .on('error', done) + .on('data', () => stream.end()) + .on('end', () => { + assert.strictEqual(lookupCount, 1); + done(); + }) + .emit('reading'); + }); + }); + }); + + describe('delete', () => { + it('should delete by key', done => { + request.request_ = (config: RequestConfig, callback: Function) => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'commit'); + assert(is.object((config.reqOpts as Any).mutations[0].delete)); + callback(null!); + }; + request.delete(key, done); + }); + + it('should return apiResponse in callback', done => { + const resp = {success: true}; + request.request_ = (config: RequestConfig, callback: Function) => { + callback(null!, resp); + }; + request.delete( + key, + (err: Error, apiResponse: [google.datastore.v1.CommitResponse]) => { + assert.ifError(err); + assert.deepStrictEqual(resp, apiResponse); + done(); + }, + ); + }); + + it('should multi delete by keys', done => { + request.request_ = (config: RequestConfig, callback: Function) => { + assert.strictEqual(config.reqOpts!.mutations!.length, 2); + callback(null!); + }; + request.delete([key, key], done); + }); + + it('should allow customization of GAX options', done => { + const gaxOptions = {}; + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.gaxOpts, gaxOptions); + done(); + }; + request.delete(key, gaxOptions, assert.ifError); + }); + + describe('transactions', () => { + beforeEach(() => { + // Trigger transaction mode. + request.id = 'transaction-id'; + request.requests_ = []; + }); + + it('should queue request', () => { + request.delete(key); + assert(is.object(request.requests_[0].mutations[0].delete)); + }); + }); + }); + + describe('get', () => { + it('should pass along readTime for reading snapshots', done => { + const savedTime = Date.now(); + request.request_ = (config: RequestConfig, callback: RequestCallback) => { + assert.deepStrictEqual(config, { + client: 'DatastoreClient', + method: 'lookup', + gaxOpts: undefined, + reqOpts: { + keys: [ + { + path: [ + { + kind: 'Company', + id: 123, + }, + ], + partitionId: {namespaceId: 'namespace'}, + }, + ], + readOptions: { + readTime: { + seconds: Math.floor(savedTime / 1000), + }, + }, + }, + }); + callback(null, { + deferred: [], + found: [], + missing: [], + readTime: {seconds: Math.floor(savedTime / 1000), nanos: 0}, + }); + }; + request.get(key, {readTime: savedTime}, (err: any) => { + if (err) { + throw err; + } + done(); + }); + }); + + describe('success', () => { + const keys = [key]; + const fakeEntities = [{a: 'a'}, {b: 'b'}]; + + beforeEach(() => { + request.createReadStream = sandbox.spy(() => { + const stream = new Transform({objectMode: true}); + setImmediate(() => { + fakeEntities.forEach(entity => stream.push(entity)); + stream.push(null); + }); + return stream; + }); + }); + + it('should return an array of entities', done => { + const options = {}; + + request.get(keys, options, (err: Error, entities: Entity[]) => { + assert.ifError(err); + assert.deepStrictEqual(entities, fakeEntities); + const spy = (request.createReadStream as Any).getCall(0); + assert.strictEqual(spy.args[0], keys); + assert.strictEqual(spy.args[1], options); + done(); + }); + }); + + it('should return a single entity', done => { + request.get(key, (err: Error, entity: Entity) => { + assert.ifError(err); + assert.strictEqual(entity, fakeEntities[0]); + done(); + }); + }); + + it('should allow options to be omitted', done => { + request.get(keys, (err: Error) => { + assert.ifError(err); + done(); + }); + }); + + it('should default options to an object', done => { + request.get(keys, null!, (err: Error) => { + assert.ifError(err); + const spy = (request.createReadStream as Any).getCall(0); + assert.deepStrictEqual(spy.args[1], {}); + done(); + }); + }); + + describe('should pass `wrapNumbers` to createReadStream', () => { + it('should pass `wrapNumbers` to createReadStream as undefined by default', done => { + request.get(keys, (err: Error) => { + assert.ifError(err); + + const createReadStreamOptions = + request.createReadStream.getCall(0).args[1]; + assert.strictEqual(createReadStreamOptions.wrapNumbers, undefined); + done(); + }); + }); + + it('should pass `wrapNumbers` to createReadStream as boolean', done => { + request.get(keys, {wrapNumbers: true}, (err: Error) => { + assert.ifError(err); + + const createReadStreamOptions = + request.createReadStream.getCall(0).args[1]; + assert.strictEqual( + typeof createReadStreamOptions.wrapNumbers, + 'boolean', + ); + done(); + }); + }); + + it('should pass `wrapNumbers` to createReadStream as IntegerTypeCastOptions', done => { + const integerTypeCastOptions = { + integerTypeCastFunction: () => {}, + properties: 'that', + }; + + request.get( + keys, + {wrapNumbers: integerTypeCastOptions}, + (err: Error) => { + assert.ifError(err); + + const createReadStreamOptions = + request.createReadStream.getCall(0).args[1]; + assert.strictEqual( + createReadStreamOptions.wrapNumbers, + integerTypeCastOptions, + ); + assert.deepStrictEqual( + createReadStreamOptions.wrapNumbers, + integerTypeCastOptions, + ); + done(); + }, + ); + }); + }); + }); + + describe('error', () => { + const error = new Error('err'); + + beforeEach(() => { + request.createReadStream = sandbox.spy(() => { + const stream = new Transform({objectMode: true}); + setImmediate(() => { + stream.emit('error', error); + }); + return stream; + }); + }); + + it('send an error to the callback', done => { + request.get(key, (err: Error) => { + assert.strictEqual(err, error); + done(); + }); + }); + }); + }); + + describe('runQueryStream', () => { + beforeEach(() => { + request.request_ = () => {}; + }); + + it('should clone the query', done => { + let query = new FakeQuery(); + query.namespace = 'namespace'; + query = extend(true, new FakeQuery(), query); + + sandbox.stub(entity, 'queryToQueryProto').callsFake(query_ => { + assert.notStrictEqual(query_, query); + assert.deepStrictEqual(query_, query); + done(); + return {} as QueryProto; + }); + + request.runQueryStream(query).on('error', done).emit('reading'); + }); + + it('should make correct request when the stream is ready', done => { + const query = {namespace: 'namespace'}; + const queryProto = {} as QueryProto; + + sandbox.stub(entity, 'queryToQueryProto').returns(queryProto); + + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'runQuery'); + assert(is.empty(config.reqOpts!.readOptions)); + assert.strictEqual(config.reqOpts!.query, queryProto); + assert.strictEqual( + config.reqOpts!.partitionId!.namespaceId, + query.namespace, + ); + assert.strictEqual(config.gaxOpts, undefined); + + done(); + }; + + request.runQueryStream(query).on('error', done).emit('reading'); + }); + + it('should allow customization of GAX options', done => { + sandbox.stub(entity, 'queryToQueryProto'); + const options = { + gaxOptions: {}, + }; + + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.gaxOpts, options.gaxOptions); + done(); + }; + + request.runQueryStream({}, options).on('error', done).emit('reading'); + }); + + it('should allow setting strong read consistency', done => { + sandbox.stub(entity, 'queryToQueryProto'); + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.reqOpts!.readOptions!.readConsistency, 1); + done(); + }; + + request + .runQueryStream({}, {consistency: 'strong'}) + .on('error', done) + .emit('reading'); + }); + + it('should allow setting strong eventual consistency', done => { + sandbox.stub(entity, 'queryToQueryProto'); + request.request_ = (config: RequestConfig) => { + assert.strictEqual(config.reqOpts!.readOptions!.readConsistency, 2); + done(); + }; + + request + .runQueryStream({}, {consistency: 'eventual'}) + .on('error', done) + .emit('reading'); + }); + + describe('error', () => { + const error = new Error('Error.'); + + beforeEach(() => { + request.request_ = (config: RequestConfig, callback: Function) => { + callback(error); + }; + }); + + it('should emit error on a stream', done => { + sandbox.stub(entity, 'queryToQueryProto'); + request + .runQueryStream({}) + .on('error', (err: Error) => { + assert.strictEqual(err, error); + done(); + }) + .emit('reading'); + }); + + it('should emit an error when encoding fails', done => { + const error = new Error('Encoding error.'); + sandbox.stub(entity, 'queryToQueryProto').throws(error); + request + .runQueryStream({}) + .on('error', (err: Error) => { + assert.strictEqual(err, error); + done(); + }) + .emit('reading'); + }); + + it('should emit an error from results decoding', done => { + const largeInt = '922337203685477850'; + const propertyName = 'points'; + sandbox.stub(entity, 'queryToQueryProto'); + + request.request_ = (config: RequestConfig, callback: Function) => { + callback(null, { + batch: { + entityResults: [ + { + entity: { + properties: { + [propertyName]: { + integerValue: largeInt, + valueType: 'integerValue', + }, + }, + }, + }, + ], + }, + }); + }; + + const stream = request.runQueryStream({}); + + stream + .on('error', (err: Error) => { + assert.deepStrictEqual( + err, + outOfBoundsError({integerValue: largeInt, propertyName}), + ); + setImmediate(() => { + assert.strictEqual(stream.destroyed, true); + done(); + }); + }) + .emit('reading'); + }); + }); + + describe('success', () => { + const entityResultsPerApiCall: Any = { + 1: [{a: true}], + 2: [{b: true}, {c: true}], + }; + + const apiResponse = { + batch: { + entityResults: [{a: true}, {b: true}, {c: true}], + endCursor: Buffer.from('abc'), + moreResults: 'MORE_RESULTS_AFTER_LIMIT', + skippedResults: 0, + }, + }; + + let formatArrayStub: Any; + beforeEach(() => { + request.request_ = (config: RequestConfig, callback: Function) => { + callback(null, apiResponse); + }; + + formatArrayStub = sandbox + .stub(entity, 'formatArray') + .callsFake(array => { + return array; + }); + }); + + it('should format results', done => { + sandbox.stub(entity, 'queryToQueryProto'); + formatArrayStub.restore(); + sandbox.stub(entity, 'formatArray').callsFake(array => { + assert.strictEqual(array, apiResponse.batch.entityResults); + return array; + }); + + const entities: Array<{}> = []; + + request + .runQueryStream({}) + .on('error', done) + .on('data', (entity: Entity) => entities.push(entity)) + .on('end', () => { + assert.deepStrictEqual(entities, apiResponse.batch.entityResults); + done(); + }); + }); + + describe('should pass `wrapNumbers` to formatArray', () => { + let wrapNumbersOpts: boolean | IntegerTypeCastOptions | undefined; + + beforeEach(() => { + sandbox.stub(entity, 'queryToQueryProto'); + formatArrayStub.restore(); + formatArrayStub = sandbox + .stub(entity, 'formatArray') + .callsFake(array => { + return array; + }); + }); + + it('should pass `wrapNumbers` to formatArray as undefined by default', done => { + request.runQueryStream({}).on('error', assert.ifError).resume(); + + setImmediate(() => { + wrapNumbersOpts = formatArrayStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbersOpts, undefined); + done(); + }); + }); + + it('should pass `wrapNumbers` to formatArray as boolean', done => { + request + .runQueryStream({}, {wrapNumbers: true}) + .on('error', assert.ifError) + .resume(); + + setImmediate(() => { + wrapNumbersOpts = formatArrayStub.getCall(0).args[1]; + assert.strictEqual(typeof wrapNumbersOpts, 'boolean'); + done(); + }); + }); + + it('should pass `wrapNumbers` to formatArray as IntegerTypeCastOptions', done => { + const integerTypeCastOptions = { + integerTypeCastFunction: () => {}, + properties: 'that', + }; + + request + .runQueryStream({}, {wrapNumbers: integerTypeCastOptions}) + .on('error', assert.ifError) + .resume(); + + setImmediate(() => { + wrapNumbersOpts = formatArrayStub.getCall(0).args[1]; + assert.strictEqual(wrapNumbersOpts, integerTypeCastOptions); + assert.deepStrictEqual(wrapNumbersOpts, integerTypeCastOptions); + done(); + }); + }); + }); + + it('should re-run query if not finished', done => { + const query = { + limitVal: 1, + offsetVal: 8, + }; + const queryProto = { + limit: { + value: query.limitVal, + }, + } as {} as QueryProto; + + let timesRequestCalled = 0; + let startCalled = false; + let offsetCalled = false; + + formatArrayStub.restore(); + sandbox.stub(entity, 'formatArray').callsFake(array => { + assert.strictEqual( + array, + entityResultsPerApiCall[timesRequestCalled], + ); + return entityResultsPerApiCall[timesRequestCalled]; + }); + + request.request_ = (config: RequestConfig, callback: Function) => { + timesRequestCalled++; + + const resp = extend(true, {}, apiResponse); + resp.batch.entityResults = + entityResultsPerApiCall[timesRequestCalled]; + + if (timesRequestCalled === 1) { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'runQuery'); + resp.batch.moreResults = 'NOT_FINISHED'; + callback(null, resp); + } else { + assert.strictEqual(startCalled, true); + assert.strictEqual(offsetCalled, true); + assert.strictEqual(config.reqOpts!.query, queryProto); + resp.batch.moreResults = 'MORE_RESULTS_AFTER_LIMIT'; + callback(null, resp); + } + }; + + FakeQuery.prototype.start = function (endCursor) { + assert.strictEqual( + endCursor, + apiResponse.batch.endCursor.toString('base64'), + ); + startCalled = true; + return this; + }; + + sandbox.stub(FakeQuery.prototype, 'offset').callsFake(offset_ => { + const offset = query.offsetVal - apiResponse.batch.skippedResults; + assert.strictEqual(offset_, offset); + offsetCalled = true; + return {} as FakeQuery; + }); + + sandbox.stub(FakeQuery.prototype, 'limit').callsFake(limit_ => { + if (timesRequestCalled === 1) { + assert.strictEqual( + limit_, + entityResultsPerApiCall[1].length - query.limitVal, + ); + } else { + // Should restore the original limit. + assert.strictEqual(limit_, query.limitVal); + } + return {} as FakeQuery; + }); + + sandbox.stub(entity, 'queryToQueryProto').callsFake(query_ => { + if (timesRequestCalled > 1) { + assert.strictEqual(query_, query); + } + return queryProto; + }); + + const entities: Array<{}> = []; + let info: Any; + + request + .runQueryStream(query) + .on('error', done) + .on('info', (_info: object) => { + info = _info; + }) + .on('data', (entity: Entity) => { + entities.push(entity); + }) + .on('end', () => { + const allResults = ([] as Array<{}>).slice + .call(entityResultsPerApiCall[1]) + .concat(entityResultsPerApiCall[2]); + + assert.deepStrictEqual(entities, allResults); + + assert.deepStrictEqual(info, { + endCursor: apiResponse.batch.endCursor.toString('base64'), + moreResults: apiResponse.batch.moreResults, + }); + + done(); + }); + }); + + it('should handle large limitless queries', done => { + let timesRequestCalled = 0; + + const query = { + limitVal: -1, + }; + + request.request_ = (_: object, callback: Function) => { + let batch; + if (++timesRequestCalled === 2) { + batch = {}; + } else { + batch = { + moreResults: 'NOT_FINISHED', + endCursor: Buffer.from('abc'), + }; + } + callback(null, {batch}); + }; + + sandbox.stub(entity, 'queryToQueryProto').returns({} as QueryProto); + const limitStub = sandbox.stub(FakeQuery.prototype, 'limit'); + + request + .runQueryStream(query) + .on('error', done) + .on('data', () => {}) + .on('end', () => { + assert.strictEqual(timesRequestCalled, 2); + assert.strictEqual(limitStub.called, false); + done(); + }); + }); + + it('should not push more results if stream was ended', done => { + let timesRequestCalled = 0; + let entitiesEmitted = 0; + + sandbox.stub(entity, 'queryToQueryProto'); + + request.request_ = (config: RequestConfig, callback: Function) => { + timesRequestCalled++; + + const resp = extend(true, {}, apiResponse); + resp.batch.entityResults = + entityResultsPerApiCall[timesRequestCalled]; + + if (timesRequestCalled === 1) { + resp.batch.moreResults = 'NOT_FINISHED'; + callback(null, resp); + } else { + resp.batch.moreResults = 'MORE_RESULTS_AFTER_LIMIT'; + callback(null, resp); + } + }; + + const stream = request + .runQueryStream({}) + .on('data', () => { + entitiesEmitted++; + stream.end(); + }) + .on('end', () => { + assert.strictEqual(entitiesEmitted, 1); + done(); + }); + }); + + it('should not get more results if stream was ended', done => { + let timesRequestCalled = 0; + sandbox.stub(entity, 'queryToQueryProto'); + request.request_ = (config: RequestConfig, callback: Function) => { + timesRequestCalled++; + callback(null!, apiResponse); + }; + + const stream = request.runQueryStream({}); + stream + .on('error', done) + .on('data', () => stream.end()) + .on('end', () => { + assert.strictEqual(timesRequestCalled, 1); + done(); + }); + }); + }); + }); + + describe('runQuery', () => { + const query = {}; + + describe('success', () => { + const fakeInfo = {}; + const fakeEntities = [{a: 'a'}, {b: 'b'}]; + + beforeEach(() => { + request.runQueryStream = sandbox.spy(() => { + const stream = new Transform({objectMode: true}); + + setImmediate(() => { + stream.emit('info', fakeInfo); + + fakeEntities.forEach(entity => { + stream.push(entity); + }); + + stream.push(null); + }); + + return stream; + }); + }); + + it('should return an array of entities', done => { + const options = {}; + + request.runQuery( + query, + options, + (err: Error | null, entities: Entity[], info: {}) => { + assert.ifError(err); + assert.deepStrictEqual(entities, fakeEntities); + assert.strictEqual(info, fakeInfo); + + const spy = request.runQueryStream.getCall(0); + assert.strictEqual(spy.args[0], query); + assert.strictEqual(spy.args[1], options); + done(); + }, + ); + }); + + describe('should pass `wrapNumbers` to runQueryStream', () => { + it('should pass `wrapNumbers` to runQueryStream as undefined by default', done => { + request.runQuery(query, (err: Error) => { + assert.ifError(err); + + const runQueryOptions = request.runQueryStream.getCall(0).args[1]; + assert.strictEqual(runQueryOptions.wrapNumbers, undefined); + done(); + }); + }); + + it('should pass `wrapNumbers` to runQueryStream boolean', done => { + request.runQuery(query, {wrapNumbers: true}, (err: Error) => { + assert.ifError(err); + + const runQueryOptions = request.runQueryStream.getCall(0).args[1]; + assert.strictEqual(typeof runQueryOptions.wrapNumbers, 'boolean'); + done(); + }); + }); + + it('should pass `wrapNumbers` to runQueryStream as IntegerTypeCastOptions', done => { + const integerTypeCastOptions = { + integerTypeCastFunction: () => {}, + properties: 'that', + }; + + request.runQuery( + query, + {wrapNumbers: integerTypeCastOptions}, + (err: Error) => { + assert.ifError(err); + + const runQueryOptions = request.runQueryStream.getCall(0).args[1]; + assert.strictEqual( + runQueryOptions.wrapNumbers, + integerTypeCastOptions, + ); + assert.deepStrictEqual( + runQueryOptions.wrapNumbers, + integerTypeCastOptions, + ); + done(); + }, + ); + }); + }); + + it('should allow options to be omitted', done => { + request.runQuery(query, (err: Error) => { + assert.ifError(err); + done(); + }); + }); + + it('should default options to an object', done => { + request.runQuery(query, null, (err: Error) => { + assert.ifError(err); + + const spy = request.runQueryStream.getCall(0); + assert.deepStrictEqual(spy.args[0], {}); + done(); + }); + }); + }); + + describe('error', () => { + const error = new Error('err'); + + beforeEach(() => { + request.runQueryStream = sandbox.spy(() => { + const stream = new Transform({objectMode: true}); + + setImmediate(() => { + stream.emit('error', error); + }); + + return stream; + }); + }); + + it('send an error to the callback', done => { + request.runQuery(query, (err: Error) => { + assert.strictEqual(err, error); + done(); + }); + }); + }); + }); + + describe('merge', () => { + let Transaction: typeof ds.Transaction; + let transaction: ds.Transaction; + const PROJECT_ID = 'project-id'; + const NAMESPACE = 'a-namespace'; + + const DATASTORE = { + request_() {}, + projectId: PROJECT_ID, + namespace: NAMESPACE, + } as {} as ds.Datastore; + + const key = { + namespace: 'ns', + kind: 'Company', + path: ['Company', null], + }; + const entityObject = {}; + + before(() => { + Transaction = proxyquire('../src/transaction.js', { + '@google-cloud/promisify': fakePfy, + }).Transaction; + }); + + beforeEach(() => { + transaction = new Transaction(DATASTORE); + + transaction.request_ = () => {}; + + transaction.commit = async () => { + return [{}] as CommitResponse; + }; + request.datastore = { + transaction: () => transaction, + }; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (transaction as any).run = (callback?: Function) => { + callback!(null); + }; + + transaction.get = async () => { + return [entityObject] as GetResponse; + }; + + transaction.commit = async () => { + return [{}] as CommitResponse; + }; + }); + + afterEach(() => sandbox.restore()); + + it('should return merge object for entity', done => { + const updatedEntityObject = { + status: 'merged', + }; + + transaction.save = (modifiedData: PrepareEntityObjectResponse) => { + assert.deepStrictEqual( + modifiedData.data, + Object.assign({}, entityObject, updatedEntityObject), + ); + }; + + request.merge({key, data: updatedEntityObject}, done); + }); + + it('should return merge objects for entities', done => { + const updatedEntityObject = [ + { + id: 1, + status: 'merged', + }, + { + id: 2, + status: 'merged', + }, + ]; + + transaction.commit = async () => { + transaction.modifiedEntities_.forEach((entity, index) => { + assert.deepStrictEqual( + entity.args[0].data, + Object.assign({}, entityObject, updatedEntityObject[index]), + ); + }); + return [{}] as CommitResponse; + }; + + request.merge( + [ + {key, data: updatedEntityObject[0]}, + {key, data: updatedEntityObject[1]}, + ], + done, + ); + }); + + it('transaction should rollback if error on transaction run!', done => { + sandbox + .stub(transaction, 'run') + .callsFake((gaxOption, callback?: Function) => { + callback = typeof gaxOption === 'function' ? gaxOption : callback!; + callback(new Error('Error')); + }); + + request.merge({key, data: null}, (err: Error) => { + assert.strictEqual(err.message, 'Error'); + done(); + }); + }); + + it('transaction should rollback if error for for transaction get!', done => { + sandbox.stub(transaction, 'get').rejects(new Error('Error')); + + request.merge({key, data: null}, (err: Error) => { + assert.strictEqual(err.message, 'Error'); + done(); + }); + }); + + it('transaction should rollback if error for for transaction commit!', done => { + sandbox.stub(transaction, 'commit').rejects(new Error('Error')); + + request.merge({key, data: null}, (err: Error) => { + assert.strictEqual(err.message, 'Error'); + done(); + }); + }); + + it('should avoid the rollback exception in transaction.run', done => { + sandbox + .stub(transaction, 'run') + .callsFake((gaxOption, callback?: Function) => { + callback = typeof gaxOption === 'function' ? gaxOption : callback!; + callback(new Error('Error.')); + }); + + sandbox + .stub(transaction, 'rollback') + .rejects(new Error('Rollback Error.')); + + request.merge({key, data: null}, (err: Error) => { + assert.strictEqual(err.message, 'Error.'); + done(); + }); + }); + + it('should avoid the rollback exception in transaction.get/commit', done => { + sandbox.restore(); + sandbox.stub(transaction, 'get').rejects(new Error('Error.')); + + sandbox + .stub(transaction, 'rollback') + .rejects(new Error('Rollback Error.')); + + request.merge({key, data: null}, (err: Error) => { + assert.strictEqual(err.message, 'Error.'); + done(); + }); + }); + }); + + describe('prepareGaxRequest_', () => { + const CONFIG = { + client: 'FakeClient', // name set at top of file + method: 'method', + reqOpts: { + a: 'b', + c: 'd', + }, + gaxOpts: { + a: 'b', + c: 'd', + }, + }; + + const PROJECT_ID = 'project-id'; + + beforeEach(() => { + const clients_ = new Map(); + clients_.set(CONFIG.client, { + [CONFIG.method]() {}, + }); + request.datastore = { + clients_, + auth: { + getProjectId(callback: Function) { + callback(null, PROJECT_ID); + }, + }, + }; + }); + + it('should get the project ID', done => { + request.datastore.auth.getProjectId = () => { + done(); + }; + request.prepareGaxRequest_(CONFIG, assert.ifError); + }); + + it('should return error if getting project ID failed', done => { + const error = new Error('Error.'); + + request.datastore.auth.getProjectId = (callback: Function) => { + callback(error); + }; + request.prepareGaxRequest_(CONFIG, (err: Error) => { + assert.strictEqual(err, error); + done(); + }); + }); + + it('should initiate and cache the client', () => { + const fakeClient = { + [CONFIG.method]() {}, + }; + v1FakeClientOverride = (options: object) => { + assert.deepStrictEqual(options, request.datastore.options); + return fakeClient; + }; + request.datastore.clients_ = new Map(); + request.prepareGaxRequest_(CONFIG, assert.ifError); + const client = request.datastore.clients_.get(CONFIG.client); + assert.strictEqual(client, fakeClient); + }); + + it('should return the cached client', done => { + v1FakeClientOverride = () => { + done(new Error('Should not re-instantiate a GAX client.')); + }; + + request.prepareGaxRequest_(CONFIG, (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + done(); + }); + }); + + it('should send gaxOpts', done => { + request.datastore.clients_ = new Map(); + request.datastore.clients_.set(CONFIG.client, { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [CONFIG.method](_: object, gaxO: any) { + delete gaxO.headers; + assert.deepStrictEqual(gaxO, CONFIG.gaxOpts); + done(); + }, + }); + + request.prepareGaxRequest_(CONFIG, (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + }); + }); + + it('should send google-cloud-resource-prefix', done => { + request.datastore.clients_ = new Map(); + request.datastore.clients_.set(CONFIG.client, { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [CONFIG.method](_: object, gaxO: any) { + assert.deepStrictEqual(gaxO.headers, { + 'google-cloud-resource-prefix': 'projects/' + PROJECT_ID, + }); + done(); + }, + }); + + request.prepareGaxRequest_(CONFIG, (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + }); + }); + + describe('commit', () => { + it('should set the mode', done => { + request.datastore.clients_ = new Map(); + request.datastore.clients_.set(CONFIG.client, { + commit(reqOpts: RequestOptions) { + assert.strictEqual(reqOpts.mode, 'NON_TRANSACTIONAL'); + done(); + }, + }); + const config = Object.assign({}, CONFIG, { + method: 'commit', + }); + request.prepareGaxRequest_( + config, + (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + }, + ); + }); + }); + + describe('transaction', () => { + const TRANSACTION_ID = 'transaction'; + + beforeEach(() => { + request.id = TRANSACTION_ID; + }); + + it('should set the commit transaction info', done => { + request.datastore.clients_ = new Map(); + request.datastore.clients_.set(CONFIG.client, { + commit(reqOpts: RequestOptions) { + assert.strictEqual(reqOpts.mode, 'TRANSACTIONAL'); + assert.strictEqual(reqOpts.transaction, TRANSACTION_ID); + done(); + }, + }); + + const config = Object.assign({}, CONFIG, { + method: 'commit', + }); + request.prepareGaxRequest_( + config, + (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + }, + ); + }); + + it('should set the rollback transaction info', done => { + request.datastore.clients_ = new Map(); + request.datastore.clients_.set(CONFIG.client, { + rollback(reqOpts: RequestOptions) { + assert.strictEqual(reqOpts.transaction, TRANSACTION_ID); + done(); + }, + }); + + const config = Object.assign({}, CONFIG, { + method: 'rollback', + }); + request.prepareGaxRequest_( + config, + (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + }, + ); + }); + + it('should set the lookup transaction info', done => { + const config = extend(true, {}, CONFIG, { + method: 'lookup', + }); + + request.datastore.clients_ = new Map(); + request.datastore.clients_.set(CONFIG.client, { + lookup(reqOpts: RequestOptions) { + assert.strictEqual( + reqOpts.readOptions!.transaction, + TRANSACTION_ID, + ); + done(); + }, + }); + + request.prepareGaxRequest_( + config, + (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + }, + ); + }); + + it('should set the runQuery transaction info', done => { + const config = extend(true, {}, CONFIG, { + method: 'runQuery', + }); + + request.datastore.clients_ = new Map(); + request.datastore.clients_.set(CONFIG.client, { + runQuery(reqOpts: RequestOptions) { + assert.strictEqual( + reqOpts.readOptions!.transaction, + TRANSACTION_ID, + ); + done(); + }, + }); + + request.prepareGaxRequest_( + config, + (err: Error, requestFn: Function) => { + assert.ifError(err); + requestFn(); + }, + ); + }); + + it('should throw if read consistency is specified', () => { + const config = extend(true, {}, CONFIG, { + method: 'runQuery', + reqOpts: { + readOptions: { + readConsistency: 1, + }, + }, + }); + + assert.throws(() => { + request.prepareGaxRequest_(config, assert.ifError); + }, /Read consistency cannot be specified in a transaction\./); + }); + }); + }); + + describe('request_', () => { + const CONFIG = {}; + + it('should pass config to prepare function', done => { + request.prepareGaxRequest_ = (config: {}) => { + assert.strictEqual(config, CONFIG); + done(); + }; + + request.request_(CONFIG, assert.ifError); + }); + + it('should execute callback with error from prepare function', done => { + const error = new Error('Error.'); + + request.prepareGaxRequest_ = (config: {}, callback: Function) => { + callback(error); + }; + + request.request_(CONFIG, (err: Error) => { + assert.strictEqual(err, error); + done(); + }); + }); + + it('should execute returned request function with callback', done => { + const requestFn = (callback: Function) => { + callback(); // done() + }; + + request.prepareGaxRequest_ = (config: {}, callback: Function) => { + callback(null, requestFn); + }; + + request.request_(CONFIG, done); + }); + }); + + describe('requestStream_', () => { + let GAX_STREAM: gax.CancellableStream = {} as gax.CancellableStream; + const CONFIG = {}; + + beforeEach(() => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (GAX_STREAM as any) = new PassThrough(); + request.prepareGaxRequest_ = (config: {}, callback: Function) => { + callback(null, () => GAX_STREAM); + }; + }); + + it('should expose an abort function', done => { + GAX_STREAM.cancel = done; + + const requestStream = request.requestStream_(CONFIG); + requestStream.emit('reading'); + requestStream.abort(); + }); + + it('should prepare the request once reading', done => { + request.prepareGaxRequest_ = (config: {}) => { + assert.strictEqual(config, CONFIG); + done(); + }; + + const requestStream = request.requestStream_(CONFIG); + requestStream.emit('reading'); + }); + + it('should destroy the stream with prepare error', done => { + const error = new Error('Error.'); + request.prepareGaxRequest_ = (config: {}, callback: Function) => { + callback(error); + }; + const requestStream = request.requestStream_(CONFIG); + requestStream.emit('reading'); + requestStream.on('error', (err: Error) => { + assert.strictEqual(err, error); + done(); + }); + }); + + it('should destroy the stream with GAX error', done => { + const error = new Error('Error.'); + const requestStream = request.requestStream_(CONFIG); + requestStream.emit('reading'); + GAX_STREAM.emit('error', error); + requestStream.on('error', (err: Error) => { + assert.strictEqual(err, error); + done(); + }); + }); + + it('should emit response from GAX stream', done => { + const response = {}; + const requestStream = request.requestStream_(CONFIG); + requestStream.emit('reading'); + requestStream.on('response', (resp: {}) => { + assert.strictEqual(resp, response); + done(); + }); + GAX_STREAM.emit('response', response); + }); + }); +}); diff --git a/handwritten/nodejs-datastore/test/transaction.ts b/handwritten/nodejs-datastore/test/transaction.ts new file mode 100644 index 00000000000..4da7bdb1710 --- /dev/null +++ b/handwritten/nodejs-datastore/test/transaction.ts @@ -0,0 +1,2943 @@ +// Copyright 2014 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import * as pfy from '@google-cloud/promisify'; +import arrify = require('arrify'); +import * as assert from 'assert'; +import {afterEach, beforeEach, before, describe, it} from 'mocha'; +import * as proxyquire from 'proxyquire'; +import {getTransactionRequest} from '../src/request'; + +import { + Datastore, + DatastoreOptions, + DatastoreRequest, + Query, + TransactionOptions, + Transaction, + AggregateField, +} from '../src'; +import {Entities, Entity, entity} from '../src/entity'; +import * as tsTypes from '../src/transaction'; +import * as sinon from 'sinon'; +import {Callback, CallOptions, ClientStub} from 'google-gax'; +import { + CommitCallback, + CreateReadStreamOptions, + GetCallback, + RequestCallback, + RequestConfig, +} from '../src/request'; +import {SECOND_DATABASE_ID} from './index'; +import {google} from '../protos/protos'; +import {RunCallback} from '../src/transaction'; +import * as protos from '../protos/protos'; +import {AggregateQuery} from '../src/aggregate'; +import {RunQueryCallback, RunQueryInfo, RunQueryOptions} from '../src/query'; +import * as mocha from 'mocha'; +const async = require('async'); + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type Any = any; +type Path = string | [string] | [string, number]; + +let promisified = false; +const fakePfy = Object.assign({}, pfy, { + promisifyAll(klass: Function, options: pfy.PromisifyAllOptions) { + if (klass.name !== 'Transaction') { + return; + } + promisified = true; + assert.deepStrictEqual(options.exclude, [ + 'createAggregationQuery', + 'createQuery', + 'delete', + 'insert', + '#runAsync', + 'save', + 'update', + 'upsert', + ]); + }, +}); + +async.each( + [{}, {databaseId: SECOND_DATABASE_ID}], + (clientOptions: DatastoreOptions) => { + describe('Transaction', () => { + let Transaction: typeof tsTypes.Transaction; + let transaction: tsTypes.Transaction; + const TRANSACTION_ID = 'transaction-id'; + const PROJECT_ID = 'project-id'; + const NAMESPACE = 'a-namespace'; + + const DEFAULT_DATASTORE = { + request_() {}, + projectId: PROJECT_ID, + namespace: NAMESPACE, + } as {} as Datastore; + + const DATASTORE = Object.assign(DEFAULT_DATASTORE, clientOptions); + + function key(path: Path) { + return new entity.Key({path: arrify(path)}); + } + + before(() => { + Transaction = proxyquire('../src/transaction.js', { + '@google-cloud/promisify': fakePfy, + }).Transaction; + }); + + beforeEach(() => { + transaction = new Transaction(DATASTORE); + }); + + describe('instantiation', () => { + it('should promisify all the things', () => { + assert(promisified); + }); + + it('should localize the datastore instance', () => { + assert.strictEqual(transaction.datastore, DATASTORE); + }); + + it('should localize the namespace', () => { + assert.strictEqual(transaction.namespace, NAMESPACE); + }); + + it('should localize the transaction ID', () => { + const options = { + id: 'transaction-id', + }; + + const transaction = new Transaction(DATASTORE, options); + assert.strictEqual(transaction.id, options.id); + }); + + it('should localize readOnly', () => { + const options = { + readOnly: true, + }; + + const transaction = new Transaction(DATASTORE, options); + assert.strictEqual(transaction.readOnly, true); + }); + + it('should localize request function', done => { + const fakeDataset: Any = { + request_: { + bind(context: {}) { + assert.strictEqual(context, fakeDataset); + + setImmediate(() => { + assert.strictEqual(transaction.request, fakeDataset.request); + done(); + }); + + return fakeDataset.request; + }, + }, + }; + + const transaction = new Transaction(fakeDataset); + }); + + it('should localize default properties', () => { + assert.deepStrictEqual(transaction.modifiedEntities_, []); + assert.deepStrictEqual(transaction.requestCallbacks_, []); + assert.deepStrictEqual(transaction.requests_, []); + }); + }); + + describe('testing various transaction functions when transaction.run returns a response', () => { + type RequestType = + | protos.google.datastore.v1.ICommitRequest + | protos.google.datastore.v1.IBeginTransactionRequest + | protos.google.datastore.v1.ILookupRequest + | protos.google.datastore.v1.IRunQueryRequest + | protos.google.datastore.v1.IRunAggregationQueryRequest; + // These tests were created to ensure that various transaction functions work correctly after run is called. + // This allows us to catch any breaking changes to code usages that should remain the same. + const testRunResp = { + transaction: Buffer.from(Array.from(Array(100).keys())), + }; + enum GapicFunctionName { + BEGIN_TRANSACTION = 'beginTransaction', + LOOKUP = 'lookup', + RUN_QUERY = 'runQuery', + RUN_AGGREGATION_QUERY = 'runAggregationQuery', + COMMIT = 'commit', + } + + // MockedTransactionWrapper is a helper class for mocking out various + // Gapic functions and ensuring that responses and errors actually make it + // back to the user. + class MockedTransactionWrapper { + datastore: Datastore; + transaction: Transaction; + dataClient?: ClientStub; + mockedBeginTransaction: Function; + functionsMocked: { + name: GapicFunctionName; + mockedFunction: Function; + }[]; + // The callBackSignaler lets the user of this object get a signal when the mocked function is called. + // This is useful for tests that need to know when the mocked function is called. + callBackSignaler: ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => void = () => {}; + + constructor( + err: Error | null = null, + resp: google.datastore.v1.IBeginTransactionResponse = testRunResp, + ) { + const namespace = 'run-without-mock'; + const projectId = 'project-id'; + const options = { + projectId, + namespace, + }; + const datastore = new Datastore(options); + const dataClientName = 'DatastoreClient'; + // Create a fresh transaction for each test because transaction state changes after a commit. + this.transaction = datastore.transaction(); + // In this before hook, save the original beginTransaction method in a variable. + // After tests are finished, reassign beginTransaction to the variable. + // This way, mocking beginTransaction in this block doesn't affect other tests. + const gapic = Object.freeze({ + v1: require('../src/v1'), + }); + // Datastore Gapic clients haven't been initialized yet, so we initialize them here. + datastore.clients_.set( + dataClientName, + new gapic.v1[dataClientName](options), + ); + const dataClient = datastore.clients_.get(dataClientName); + // Mock begin transaction + this.mockedBeginTransaction = () => {}; + if (dataClient && dataClient.beginTransaction) { + this.mockedBeginTransaction = dataClient.beginTransaction; + } + if (dataClient && dataClient.beginTransaction) { + dataClient.beginTransaction = ( + request: protos.google.datastore.v1.IBeginTransactionRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + | protos.google.datastore.v1.IBeginTransactionRequest + | null + | undefined, + {} | null | undefined + >, + ) => { + // Calls a user provided function that will receive this string + // Usually used to track when this code was reached relative to other code + this.callBackSignaler( + GapicFunctionName.BEGIN_TRANSACTION, + request, + ); + callback(err, resp); + }; + } + this.dataClient = dataClient; + this.functionsMocked = []; + this.datastore = datastore; + } + + // This mocks out a gapic function to just call the callback received in the Gapic function. + // The callback will send back the error and response arguments provided as parameters. + mockGapicFunction( + functionName: GapicFunctionName, + response: ResponseType, + error: Error | null, + ) { + const dataClient = this.dataClient; + // Check here that function hasn't been mocked out already + // Ensures that this mocking object is not being misused. + this.functionsMocked.forEach(fn => { + if (fn.name === functionName) { + throw Error(`${functionName} has already been mocked out`); + } + }); + if (dataClient && dataClient[functionName]) { + this.functionsMocked.push({ + name: functionName, + mockedFunction: dataClient[functionName], + }); + } + if (dataClient && dataClient[functionName]) { + dataClient[functionName] = ( + request: RequestType, + options: CallOptions, + callback: Callback< + ResponseType, + RequestType | null | undefined, + {} | null | undefined + >, + ) => { + this.callBackSignaler(functionName, request); + callback(error, response); + }; + } + } + + // This resets beginTransaction from the Gapic layer to what it originally was. + // Resetting beginTransaction ensures other tests don't use the beginTransaction mock. + resetBeginTransaction() { + if (this.dataClient && this.dataClient.beginTransaction) { + this.dataClient.beginTransaction = this.mockedBeginTransaction; + } + } + + // This resets Gapic functions mocked out by the tests to what they originally were. + // Resetting mocked out Gapic functions ensures other tests don't use these mocked out functions. + resetGapicFunctions() { + this.functionsMocked.forEach(functionMocked => { + if (this.dataClient) { + this.dataClient[functionMocked.name] = + functionMocked.mockedFunction; + } + }); + } + } + + let transactionWrapper: MockedTransactionWrapper; + let transaction: Transaction; + + afterEach(() => { + transactionWrapper.resetBeginTransaction(); + transactionWrapper.resetGapicFunctions(); + }); + + describe('sending an error back from the beginTransaction gapic function', () => { + const testErrorMessage = 'test-beginTransaction-error'; + beforeEach(async () => { + transactionWrapper = new MockedTransactionWrapper( + new Error(testErrorMessage), + undefined, + ); + }); + it('should send back the error when awaiting a promise', async () => { + try { + await transactionWrapper.transaction.commit(); + assert.fail('The run call should have failed.'); + } catch (error: any) { + assert.strictEqual(error['message'], testErrorMessage); + } + }); + it('should send back the error when using a callback', done => { + const commitCallback: CommitCallback = ( + error: Error | null | undefined, + response?: google.datastore.v1.ICommitResponse, + ) => { + try { + assert(error); + assert.strictEqual(error.message, testErrorMessage); + assert.deepStrictEqual(response, undefined); + done(); + } catch (e) { + done(e); + } + }; + transactionWrapper.transaction.commit(commitCallback); + }); + }); + + describe('commit', () => { + // These tests were created to catch regressions for transaction.commit changes. + const testCommitResp = { + mutationResults: [ + { + key: { + path: [ + { + kind: 'some-kind', + }, + ], + }, + }, + ], + }; + const testErrorMessage = 'test-commit-error'; + + beforeEach(async () => { + transactionWrapper = new MockedTransactionWrapper(); + }); + + describe('should pass error back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.COMMIT, + testCommitResp, + new Error(testErrorMessage), + ); + }); + + it('should send back the error when awaiting a promise', async () => { + try { + await transactionWrapper.transaction.run(); + await transactionWrapper.transaction.commit(); + assert.fail('The run call should have failed.'); + } catch (error: any) { + assert.strictEqual(error['message'], testErrorMessage); + } + }); + it('should send back the error when using a callback', done => { + const commitCallback: CommitCallback = ( + error: Error | null | undefined, + response?: google.datastore.v1.ICommitResponse, + ) => { + try { + assert(error); + assert.strictEqual(error.message, testErrorMessage); + assert.strictEqual(response, testCommitResp); + done(); + } catch (e) { + done(e); + } + }; + transactionWrapper.transaction.run(() => { + transactionWrapper.transaction.commit(commitCallback); + }); + }); + }); + describe('should pass response back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.COMMIT, + testCommitResp, + null, + ); + }); + it('should send back the response when awaiting a promise', async () => { + await transactionWrapper.transaction.run(); + const [commitResults] = + await transactionWrapper.transaction.commit(); + assert.strictEqual(commitResults, testCommitResp); + }); + it('should send back the response when using a callback', done => { + const commitCallback: CommitCallback = ( + error: Error | null | undefined, + response?: google.datastore.v1.ICommitResponse, + ) => { + try { + assert.strictEqual(error, null); + assert.strictEqual(response, testCommitResp); + done(); + } catch (e) { + done(e); + } + }; + transactionWrapper.transaction.run(() => { + transactionWrapper.transaction.commit(commitCallback); + }); + }); + }); + }); + describe('runAggregationQuery', () => { + // These tests were created to catch regressions for transaction.runAggregationQuery changes. + const runAggregationQueryUserResp = [{'average rating': 100}]; + const runAggregationQueryResp = { + batch: { + aggregationResults: [ + { + aggregateProperties: { + 'average rating': { + meaning: 0, + excludeFromIndexes: false, + doubleValue: 100, + valueType: 'doubleValue', + }, + }, + }, + ], + moreResults: + google.datastore.v1.QueryResultBatch.MoreResultsType + .NO_MORE_RESULTS, + readTime: {seconds: '1699390681', nanos: 961667000}, + }, + query: null, + transaction: testRunResp.transaction, + }; + const testErrorMessage = 'test-run-Aggregate-Query-error'; + let aggregate: AggregateQuery; + + beforeEach(async () => { + transactionWrapper = new MockedTransactionWrapper(); + transaction = transactionWrapper.transaction; + const q = transactionWrapper.datastore.createQuery('Character'); + aggregate = transactionWrapper.datastore + .createAggregationQuery(q) + .addAggregation(AggregateField.average('appearances')); + }); + + describe('should pass error back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_AGGREGATION_QUERY, + runAggregationQueryResp, + new Error(testErrorMessage), + ); + }); + + it('should send back the error when awaiting a promise', async () => { + try { + await transaction.run(); + await transaction.runAggregationQuery(aggregate); + assert.fail('The run call should have failed.'); + } catch (error: any) { + assert.strictEqual(error['message'], testErrorMessage); + } + }); + it('should send back the error when using a callback', done => { + const runAggregateQueryCallback: RequestCallback = ( + error: Error | null | undefined, + response?: unknown, + ) => { + try { + assert(error); + assert.strictEqual(error.message, testErrorMessage); + assert.deepStrictEqual(response, runAggregationQueryUserResp); + done(); + } catch (e) { + done(e); + } + }; + transaction.run(() => { + transaction.runAggregationQuery( + aggregate, + runAggregateQueryCallback, + ); + }); + }); + }); + describe('should pass response back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_AGGREGATION_QUERY, + runAggregationQueryResp, + null, + ); + }); + it('should send back the response when awaiting a promise', async () => { + await transaction.run(); + const allResults = + await transaction.runAggregationQuery(aggregate); + const [runAggregateQueryResults] = allResults; + assert.deepStrictEqual( + runAggregateQueryResults, + runAggregationQueryUserResp, + ); + }); + it('should send back the response when using a callback', done => { + const runAggregateQueryCallback: CommitCallback = ( + error: Error | null | undefined, + response?: unknown, + ) => { + try { + assert.strictEqual(error, null); + assert.deepStrictEqual(response, runAggregationQueryUserResp); + done(); + } catch (e) { + done(e); + } + }; + transaction.run(() => { + transaction.runAggregationQuery( + aggregate, + runAggregateQueryCallback, + ); + }); + }); + }); + }); + describe('runQuery', () => { + // These tests were created to catch regressions for transaction.runQuery changes. + const runQueryResp = { + batch: { + entityResults: [], + endCursor: { + type: 'Buffer', + data: Buffer.from(Array.from(Array(100).keys())), + }, + }, + }; + const runQueryUserResp: Entity[] = []; + const runQueryUserInfo: RunQueryInfo = { + moreResults: undefined, + endCursor: '[object Object]', + }; + const testErrorMessage = 'test-run-Query-error'; + let q: Query; + + beforeEach(async () => { + transactionWrapper = new MockedTransactionWrapper(); + transaction = transactionWrapper.transaction; + q = transactionWrapper.datastore.createQuery('Character'); + }); + + describe('should pass error back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_QUERY, + runQueryResp, + new Error(testErrorMessage), + ); + }); + + it('should send back the error when awaiting a promise', async () => { + try { + await transaction.run(); + await transaction.runQuery(q); + assert.fail('The run call should have failed.'); + } catch (error: any) { + assert.strictEqual(error['message'], testErrorMessage); + } + }); + it('should send back the error when using a callback', done => { + const callback: RunQueryCallback = ( + error: Error | null | undefined, + entities?: Entity[], + info?: RunQueryInfo, + ) => { + try { + assert(error); + assert.strictEqual(error.message, testErrorMessage); + assert.deepStrictEqual(entities, undefined); + assert.deepStrictEqual(info, undefined); + done(); + } catch (e) { + done(e); + } + }; + transaction.run(() => { + transaction.runQuery(q, callback); + }); + }); + }); + describe('should pass response back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_QUERY, + runQueryResp, + null, + ); + }); + it('should send back the response when awaiting a promise', async () => { + await transaction.run(); + const [runQueryResults, info] = await transaction.runQuery(q); + assert.deepStrictEqual(runQueryResults, runQueryUserResp); + assert.deepStrictEqual(info, runQueryUserInfo); + }); + it('should send back the response when using a callback', done => { + const callback: RunQueryCallback = ( + error: Error | null | undefined, + entities?: Entity[], + info?: RunQueryInfo, + ) => { + try { + assert.strictEqual(error, null); + assert.deepStrictEqual(entities, runQueryUserResp); + assert.deepStrictEqual(info, runQueryUserInfo); + done(); + } catch (e) { + done(e); + } + }; + transaction.run(() => { + transaction.runQuery(q, callback); + }); + }); + }); + }); + describe('get', () => { + // These tests were created to catch regressions for transaction.get changes. + const getResp = { + found: [ + { + entity: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + idType: 'name', + }, + ], + partitionId: { + projectId: 'projectId', + databaseId: 'databaseId', + namespaceId: 'namespaceId', + }, + }, + excludeFromIndexes: false, + properties: {}, + }, + }, + ], + missing: [], + deferred: [], + transaction: testRunResp.transaction, + readTime: { + seconds: '1699470605', + nanos: 201398000, + }, + }; + const getUserResp = 'post1'; + const testErrorMessage = 'test-run-Query-error'; + let key: entity.Key; + + beforeEach(async () => { + transactionWrapper = new MockedTransactionWrapper(); + transaction = transactionWrapper.transaction; + key = transactionWrapper.datastore.key(['Company', 'Google']); + }); + + describe('should pass error back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.LOOKUP, + getResp, + new Error(testErrorMessage), + ); + }); + + it('should send back the error when awaiting a promise', async () => { + try { + await transaction.run(); + await transaction.get(key); + assert.fail('The run call should have failed.'); + } catch (error: any) { + assert.strictEqual(error['message'], testErrorMessage); + } + }); + it('should send back the error when using a callback', done => { + const callback: GetCallback = ( + err?: Error | null, + entity?: Entities, + ) => { + try { + assert(err); + assert.strictEqual(err.message, testErrorMessage); + assert.deepStrictEqual(entity, undefined); + done(); + } catch (e) { + done(e); + } + }; + transaction.run(() => { + transaction.get(key, callback); + }); + }); + }); + describe('should pass response back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.LOOKUP, + getResp, + null, + ); + }); + it('should send back the response when awaiting a promise', async () => { + await transaction.run(); + const [results] = await transaction.get(key); + const result = results[transactionWrapper.datastore.KEY]; + assert.deepStrictEqual(result.name, getUserResp); + }); + it('should send back the response when using a callback', done => { + const callback: GetCallback = ( + err?: Error | null, + entity?: Entities, + ) => { + try { + const result = entity[transactionWrapper.datastore.KEY]; + assert.strictEqual(err, null); + assert.deepStrictEqual(result.name, getUserResp); + done(); + } catch (e) { + done(e); + } + }; + transaction.run(() => { + transaction.get(key, callback); + }); + }); + }); + }); + describe('concurrency', async () => { + // Items in this enum represent different points in time in the user code. + enum UserCodeEvent { + RUN_CALLBACK, + COMMIT_CALLBACK, + GET_CALLBACK, + RUN_QUERY_CALLBACK, + RUN_AGGREGATION_QUERY_CALLBACK, + CUSTOM_EVENT, + } + // A transaction event represents a point in time particular code is reached + // when running code that uses a transaction. + type TransactionEvent = GapicFunctionName | UserCodeEvent; + + // This object is a sample response from 'commit' in the Gapic layer. + const testCommitResp = { + mutationResults: [ + { + key: { + path: [ + { + kind: 'some-kind', + }, + ], + }, + }, + ], + }; + // This object is a sample response from 'lookup' in the Gapic layer. + const testLookupResp = { + found: [ + { + entity: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + idType: 'name', + }, + ], + partitionId: { + projectId: 'projectId', + databaseId: 'databaseId', + namespaceId: 'namespaceId', + }, + }, + excludeFromIndexes: false, + properties: {}, + }, + }, + ], + missing: [], + deferred: [], + transaction: testRunResp.transaction, + readTime: { + seconds: '1699470605', + nanos: 201398000, + }, + }; + // This object is a sample response from 'runQuery' in the Gapic layer. + const testRunQueryResp = { + batch: { + entityResults: [], + endCursor: { + type: 'Buffer', + data: Buffer.from(Array.from(Array(100).keys())), + }, + }, + }; + // This object is a sample response from 'runAggregationQuery' in the Gapic layer. + const testRunAggregationQueryResp = { + batch: { + aggregationResults: [ + { + aggregateProperties: { + 'average rating': { + meaning: 0, + excludeFromIndexes: false, + doubleValue: 100, + valueType: 'doubleValue', + }, + }, + }, + ], + moreResults: + google.datastore.v1.QueryResultBatch.MoreResultsType + .NO_MORE_RESULTS, + readTime: {seconds: '1699390681', nanos: 961667000}, + }, + query: null, + transaction: testRunResp.transaction, + }; + let transactionWrapper: MockedTransactionWrapper; + let transaction: Transaction; + + beforeEach(async () => { + transactionWrapper = new MockedTransactionWrapper(); + transaction = transactionWrapper.transaction; + }); + + afterEach(() => { + transactionWrapper.resetBeginTransaction(); + transactionWrapper.resetGapicFunctions(); + }); + + type GapicRequestData = { + call: GapicFunctionName; + request?: RequestType; + }; + + /** + * This object is used for testing the order that different events occur. + * The events can include user code reached, gapic code reached and callbacks called. + * + * @param {MockedTransactionWrapper} [transactionWrapper] A TransactionWrapper instance. + * @param {mocha.Done} [done] A function for signalling the test is complete. + * @param {TransactionEvent[]} [expectedOrder] The order events are expected to occur. + * @param {MockedTransactionWrapper} [transactionWrapper] A TransactionWrapper instance. + */ + class TransactionOrderTester { + /** + * expectedRequests equal the request data in the order they are expected to + * be passed into the Gapic layer. + * @private + */ + readonly expectedRequests?: GapicRequestData[]; + /** + * requests are the actual order of the requests that are passed into the + * gapic layer + * @private + */ + readonly requests: GapicRequestData[] = []; + /** + * expectedEventOrder is the order the test expects different events to occur + * such as a callback being called, Gapic functions being called or user + * code being run. + */ + readonly expectedEventOrder: TransactionEvent[] = []; + /** + * eventOrder is the order events actually occur in the test and will be compared with + * expectedEventOrder. + * @private + */ + eventOrder: TransactionEvent[] = []; + // A transaction wrapper object is used to contain the transaction and mocked Gapic functions. + #transactionWrapper: MockedTransactionWrapper; + // Stores the mocha done function so that it can be called from this object. + readonly #done: mocha.Done; + + /** + * Each time an event occurs this function is called to check to see if all + * events happened that were supposed to happen. If all events in the test + * happened then this function passes tests if the events happened in the + * right order. + */ + checkForCompletion() { + if (this.eventOrder.length >= this.expectedEventOrder.length) { + try { + assert.deepStrictEqual( + this.eventOrder, + this.expectedEventOrder, + ); + if (this.expectedRequests) { + assert.deepStrictEqual( + this.requests, + this.expectedRequests, + ); + } + this.#done(); + } catch (e) { + this.#done(e); + } + } + } + + constructor( + transactionWrapper: MockedTransactionWrapper, + done: mocha.Done, + expectedOrder: TransactionEvent[], + expectedRequests?: { + call: GapicFunctionName; + request?: RequestType; + }[], + ) { + this.expectedEventOrder = expectedOrder; + this.expectedRequests = expectedRequests; + this.#done = done; + transactionWrapper.callBackSignaler = ( + call: GapicFunctionName, + request?: RequestType, + ) => { + try { + this.requests.push({call, request}); + this.eventOrder.push(call); + this.checkForCompletion(); + } catch (e) { + done(e); + } + }; + this.#transactionWrapper = transactionWrapper; + } + + /** + * Returns a callback that will record an event so that order of events + * can be compared later. + * + * @param {UserCodeEvent} [event] The event that should be recorded. + */ + push(event: UserCodeEvent) { + return () => { + try { + this.eventOrder.push(event); + this.checkForCompletion(); + } catch (e) { + this.#done(e); + } + }; + } + } + + describe('should pass response back to the user', async () => { + beforeEach(() => { + transactionWrapper.mockGapicFunction( + GapicFunctionName.COMMIT, + testCommitResp, + null, + ); + }); + + it('should call the callbacks in the proper order with run and commit', done => { + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + UserCodeEvent.CUSTOM_EVENT, + GapicFunctionName.BEGIN_TRANSACTION, + UserCodeEvent.RUN_CALLBACK, + GapicFunctionName.COMMIT, + UserCodeEvent.COMMIT_CALLBACK, + ], + ); + transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); + transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); + tester.push(UserCodeEvent.CUSTOM_EVENT)(); + }); + it('should call the callbacks in the proper order with commit', done => { + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + UserCodeEvent.CUSTOM_EVENT, + GapicFunctionName.BEGIN_TRANSACTION, + GapicFunctionName.COMMIT, + UserCodeEvent.COMMIT_CALLBACK, + ], + ); + transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); + tester.push(UserCodeEvent.CUSTOM_EVENT)(); + }); + it('should call the callbacks in the proper order with two run calls', done => { + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + UserCodeEvent.CUSTOM_EVENT, + GapicFunctionName.BEGIN_TRANSACTION, + UserCodeEvent.RUN_CALLBACK, + UserCodeEvent.RUN_CALLBACK, + ], + ); + transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); + transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); + tester.push(UserCodeEvent.CUSTOM_EVENT)(); + }); + it('should call the callbacks in the proper order with commit and then run', done => { + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + UserCodeEvent.CUSTOM_EVENT, + GapicFunctionName.BEGIN_TRANSACTION, + UserCodeEvent.RUN_CALLBACK, + GapicFunctionName.COMMIT, + UserCodeEvent.COMMIT_CALLBACK, + ], + ); + transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); + transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); + tester.push(UserCodeEvent.CUSTOM_EVENT)(); + }); + }); + describe('should pass response back to the user and check the request', async () => { + let key: entity.Key; + beforeEach(() => { + key = transactionWrapper.datastore.key(['Company', 'Google']); + transactionWrapper.mockGapicFunction( + GapicFunctionName.COMMIT, + testCommitResp, + null, + ); + transactionWrapper.mockGapicFunction( + GapicFunctionName.LOOKUP, + testLookupResp, + null, + ); + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_QUERY, + testRunQueryResp, + null, + ); + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_AGGREGATION_QUERY, + testRunAggregationQueryResp, + null, + ); + }); + const beginTransactionRequest = { + transactionOptions: {}, + projectId: 'project-id', + }; + const commitRequest = { + mode: 'TRANSACTIONAL', + transaction: testRunResp.transaction, + projectId: 'project-id', + mutations: [ + { + upsert: { + properties: {}, + key: { + partitionId: { + namespaceId: 'run-without-mock', + }, + path: [ + { + kind: 'Company', + name: 'Google', + }, + ], + }, + }, + }, + ], + }; + const lookupTransactionRequest = { + keys: [ + { + partitionId: { + namespaceId: 'run-without-mock', + }, + path: [ + { + kind: 'Company', + name: 'Google', + }, + ], + }, + ], + projectId: 'project-id', + readOptions: { + transaction: testRunResp.transaction, + }, + }; + const lookupTransactionRequestWithNewTransaction = { + keys: [ + { + partitionId: { + namespaceId: 'run-without-mock', + }, + path: [ + { + kind: 'Company', + name: 'Google', + }, + ], + }, + ], + projectId: 'project-id', + readOptions: { + newTransaction: {}, + consistencyType: 'newTransaction', + transaction: testRunResp.transaction, + }, + }; + describe('put, commit', () => { + const expectedRequests = [ + { + call: GapicFunctionName.BEGIN_TRANSACTION, + request: beginTransactionRequest, + }, + { + call: GapicFunctionName.COMMIT, + request: commitRequest, + }, + ]; + it('should verify that there is a BeginTransaction call while beginning later', done => { + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + GapicFunctionName.BEGIN_TRANSACTION, + GapicFunctionName.COMMIT, + UserCodeEvent.COMMIT_CALLBACK, + ], + expectedRequests, + ); + transaction.save({ + key, + data: '', + }); + transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); + }); + it('should verify that there is a BeginTransaction call while beginning early', done => { + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + GapicFunctionName.BEGIN_TRANSACTION, + UserCodeEvent.RUN_CALLBACK, + GapicFunctionName.COMMIT, + UserCodeEvent.COMMIT_CALLBACK, + ], + expectedRequests, + ); + transaction.save({ + key, + data: '', + }); + transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); + transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); + }); + }); + describe('lookup, lookup, put, commit', () => { + it('should verify that there is no BeginTransaction call while beginning later', done => { + const expectedRequests = [ + { + call: GapicFunctionName.BEGIN_TRANSACTION, + request: beginTransactionRequest, + }, + { + call: GapicFunctionName.COMMIT, + request: commitRequest, + }, + { + call: GapicFunctionName.LOOKUP, + request: lookupTransactionRequestWithNewTransaction, + }, + { + call: GapicFunctionName.LOOKUP, + request: lookupTransactionRequestWithNewTransaction, + }, + ]; + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + GapicFunctionName.BEGIN_TRANSACTION, + GapicFunctionName.COMMIT, + UserCodeEvent.COMMIT_CALLBACK, + GapicFunctionName.LOOKUP, + GapicFunctionName.LOOKUP, + UserCodeEvent.GET_CALLBACK, + UserCodeEvent.GET_CALLBACK, + ], + expectedRequests, + ); + transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); + transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); + transactionWrapper.transaction.save({ + key, + data: '', + }); + transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); + }); + it('should verify that there is a BeginTransaction call while beginning early', done => { + const expectedRequests = [ + { + call: GapicFunctionName.BEGIN_TRANSACTION, + request: beginTransactionRequest, + }, + { + call: GapicFunctionName.COMMIT, + request: commitRequest, + }, + { + call: GapicFunctionName.LOOKUP, + request: lookupTransactionRequest, + }, + { + call: GapicFunctionName.LOOKUP, + request: lookupTransactionRequest, + }, + ]; + const tester = new TransactionOrderTester( + transactionWrapper, + done, + [ + GapicFunctionName.BEGIN_TRANSACTION, + UserCodeEvent.RUN_CALLBACK, + GapicFunctionName.COMMIT, + UserCodeEvent.COMMIT_CALLBACK, + GapicFunctionName.LOOKUP, + GapicFunctionName.LOOKUP, + UserCodeEvent.GET_CALLBACK, + UserCodeEvent.GET_CALLBACK, + ], + expectedRequests, + ); + transaction.run(tester.push(UserCodeEvent.RUN_CALLBACK)); + transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); + transaction.get(key, tester.push(UserCodeEvent.GET_CALLBACK)); + transactionWrapper.transaction.save({ + key, + data: '', + }); + transaction.commit(tester.push(UserCodeEvent.COMMIT_CALLBACK)); + }); + }); + }); + }); + describe('Testing requests passed into the gapic layer', () => { + let key: entity.Key; + const testCommitResp = { + mutationResults: [ + { + key: { + path: [ + { + kind: 'some-kind', + }, + ], + }, + }, + ], + }; + const runQueryResp = { + batch: { + entityResults: [], + endCursor: { + type: 'Buffer', + data: Buffer.from(Array.from(Array(100).keys())), + }, + }, + transaction: testRunResp.transaction, + }; + const runAggregationQueryResp = { + batch: { + aggregationResults: [ + { + aggregateProperties: { + 'average rating': { + meaning: 0, + excludeFromIndexes: false, + doubleValue: 100, + valueType: 'doubleValue', + }, + }, + }, + ], + moreResults: + google.datastore.v1.QueryResultBatch.MoreResultsType + .NO_MORE_RESULTS, + readTime: {seconds: '1699390681', nanos: 961667000}, + }, + query: null, + transaction: testRunResp.transaction, + }; + const getResp = { + found: [ + { + entity: { + key: { + path: [ + { + kind: 'Post', + name: 'post1', + idType: 'name', + }, + ], + partitionId: { + projectId: 'projectId', + databaseId: 'databaseId', + namespaceId: 'namespaceId', + }, + }, + excludeFromIndexes: false, + properties: {}, + }, + }, + ], + missing: [], + deferred: [], + transaction: testRunResp.transaction, + readTime: { + seconds: '1699470605', + nanos: 201398000, + }, + }; + afterEach(() => { + transactionWrapper.resetBeginTransaction(); + transactionWrapper.resetGapicFunctions(); + }); + beforeEach(async () => { + transactionWrapper = new MockedTransactionWrapper(); + key = transactionWrapper.datastore.key(['Company', 'Google']); + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_AGGREGATION_QUERY, + runAggregationQueryResp, + null, + ); + transactionWrapper.mockGapicFunction( + GapicFunctionName.LOOKUP, + getResp, + null, + ); + transactionWrapper.mockGapicFunction( + GapicFunctionName.RUN_QUERY, + runQueryResp, + null, + ); + transactionWrapper.mockGapicFunction( + GapicFunctionName.COMMIT, + testCommitResp, + null, + ); + }); + describe('lookup, lookup, put, commit', () => { + it('without using transaction.run', done => { + let lookupCallCount = 0; + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + throw Error( + 'BeginTransaction should not have been called', + ); + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + switch (lookupCallCount) { + case 0: + assert.deepStrictEqual(lookupRequest.readOptions, { + newTransaction: {}, + consistencyType: 'newTransaction', + }); + break; + case 1: + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + default: + throw Error('Lookup was called too many times'); + } + lookupCallCount++; + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + await transaction.get(key); + await transaction.get(key); + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + it('with using transaction.run', done => { + let beginCount = 0; + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + assert.deepStrictEqual(request, { + projectId: 'project-id', + transactionOptions: {}, + }); + beginCount++; + break; + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + assert.strictEqual(beginCount, 1); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + await transaction.run(); + await transaction.get(key); + await transaction.get(key); + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + }); + describe('runQuery, lookup, put, commit', () => { + it('without using transaction.run', done => { + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + throw Error( + 'BeginTransaction should not have been called', + ); + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.RUN_QUERY: { + const runQueryRequest = + request as protos.google.datastore.v1.IRunQueryRequest; + assert.deepStrictEqual(runQueryRequest.readOptions, { + newTransaction: {}, + consistencyType: 'newTransaction', + }); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + const query = + transactionWrapper.datastore.createQuery('Task'); + await transaction.runQuery(query); + await transaction.get(key); + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + it('with using transaction.run', done => { + let beginCount = 0; + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + assert.deepStrictEqual(request, { + projectId: 'project-id', + transactionOptions: {}, + }); + beginCount++; + break; + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.RUN_QUERY: { + const runQueryRequest = + request as protos.google.datastore.v1.IRunQueryRequest; + assert.deepStrictEqual(runQueryRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + assert.strictEqual(beginCount, 1); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + await transaction.run(); + const query = + transactionWrapper.datastore.createQuery('Task'); + await transaction.runQuery(query); + await transaction.get(key); + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + }); + describe('runAggregationQuery, lookup, put, commit', () => { + it('without using transaction.run', done => { + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + throw Error( + 'BeginTransaction should not have been called', + ); + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.RUN_AGGREGATION_QUERY: { + const runAggregationQueryRequest = + request as protos.google.datastore.v1.IRunAggregationQueryRequest; + assert.deepStrictEqual( + runAggregationQueryRequest.readOptions, + { + newTransaction: {}, + consistencyType: 'newTransaction', + }, + ); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + const query = + transactionWrapper.datastore.createQuery('Task'); + const aggregate = transactionWrapper.datastore + .createAggregationQuery(query) + .addAggregation(AggregateField.average('appearances')); + await transaction.runAggregationQuery(aggregate); + await transaction.get(key); + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + it('with using transaction.run', done => { + let beginCount = 0; + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + beginCount++; + assert.deepStrictEqual(request, { + projectId: 'project-id', + transactionOptions: {}, + }); + break; + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.RUN_AGGREGATION_QUERY: { + const runAggregationQueryRequest = + request as protos.google.datastore.v1.IRunAggregationQueryRequest; + assert.deepStrictEqual( + runAggregationQueryRequest.readOptions, + { + transaction: testRunResp.transaction, + }, + ); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + assert.strictEqual(beginCount, 1); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + await transaction.run(); + const query = + transactionWrapper.datastore.createQuery('Task'); + const aggregate = transactionWrapper.datastore + .createAggregationQuery(query) + .addAggregation(AggregateField.average('appearances')); + await transaction.runAggregationQuery(aggregate); + await transaction.get(key); + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + }); + describe('put, put, lookup, commit', () => { + it('without using transaction.run', done => { + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + throw Error( + 'BeginTransaction should not have been called', + ); + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + newTransaction: {}, + consistencyType: 'newTransaction', + }); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + transaction.save({key, data: ''}); + transaction.save({key, data: 'more-data'}); + await transaction.get(key); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + it('with using transaction.run', done => { + let beginCount = 0; + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + assert.deepStrictEqual(request, { + projectId: 'project-id', + transactionOptions: {}, + }); + beginCount++; + break; + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + assert.strictEqual(beginCount, 1); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + await transaction.run(); + transaction.save({key, data: ''}); + transaction.save({key, data: 'more-data'}); + await transaction.get(key); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + }); + describe('put, commit', () => { + it('without using transaction.run', done => { + let beginCount = 0; + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + assert.deepStrictEqual(request, { + projectId: 'project-id', + transactionOptions: {}, + }); + beginCount++; + break; + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + assert.strictEqual(beginCount, 1); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + it('with using transaction.run', done => { + // This gets called when the program reaches the gapic layer. + // It ensures the data that reaches the gapic layer is correct. + let beginCount = 0; + transactionWrapper.callBackSignaler = ( + callbackReached: GapicFunctionName, + request?: RequestType, + ) => { + try { + switch (callbackReached) { + case GapicFunctionName.BEGIN_TRANSACTION: + assert.deepStrictEqual(request, { + projectId: 'project-id', + transactionOptions: {}, + }); + beginCount++; + break; + case GapicFunctionName.LOOKUP: { + const lookupRequest = + request as protos.google.datastore.v1.ILookupRequest; + assert.deepStrictEqual(lookupRequest.readOptions, { + transaction: testRunResp.transaction, + }); + break; + } + case GapicFunctionName.COMMIT: { + const commitRequest = + request as protos.google.datastore.v1.ICommitRequest; + assert.deepStrictEqual( + commitRequest.mode, + 'TRANSACTIONAL', + ); + assert.deepStrictEqual( + commitRequest.transaction, + testRunResp.transaction, + ); + assert.strictEqual(beginCount, 1); + done(); + break; + } + default: + throw Error( + 'A gapic function was called that should not have been called', + ); + } + } catch (err: any) { + done(err); + } + }; + void (async () => { + try { + transaction = transactionWrapper.transaction; + await transaction.run(); + transaction.save({key, data: ''}); + await transaction.commit(); + } catch (err: any) { + done(err); + } + })(); + }); + }); + }); + }); + + describe('run without setting up transaction id', () => { + // These tests were created so that when transaction.run is restructured we + // can be confident that it works the same way as before. + const testRunResp = { + transaction: Buffer.from(Array.from(Array(100).keys())), + }; + const namespace = 'run-without-mock'; + const projectId = 'project-id'; + const testErrorMessage = 'test-error'; + const options = { + projectId, + namespace, + }; + const datastore = new Datastore(options); + const transactionWithoutMock = datastore.transaction(); + const dataClientName = 'DatastoreClient'; + let dataClient: ClientStub | undefined; + let originalBeginTransactionMethod: Function; + + beforeEach(async () => { + // In this before hook, save the original beginTransaction method in a variable. + // After tests are finished, reassign beginTransaction to the variable. + // This way, mocking beginTransaction in this block doesn't affect other tests. + const gapic = Object.freeze({ + v1: require('../src/v1'), + }); + // Datastore Gapic clients haven't been initialized yet, so we initialize them here. + datastore.clients_.set( + dataClientName, + new gapic.v1[dataClientName](options), + ); + dataClient = datastore.clients_.get(dataClientName); + if (dataClient && dataClient.beginTransaction) { + originalBeginTransactionMethod = dataClient.beginTransaction; + } + }); + + afterEach(() => { + // beginTransaction has likely been mocked out in these tests. + // We should reassign beginTransaction back to its original value for tests outside this block. + if (dataClient && originalBeginTransactionMethod) { + dataClient.beginTransaction = originalBeginTransactionMethod; + } + }); + + function setupBeginTransaction(err: Error | null | undefined) { + if (dataClient) { + dataClient.beginTransaction = ( + request: protos.google.datastore.v1.IBeginTransactionRequest, + options: CallOptions, + callback: Callback< + protos.google.datastore.v1.IBeginTransactionResponse, + | protos.google.datastore.v1.IBeginTransactionRequest + | null + | undefined, + {} | null | undefined + >, + ) => { + callback(err, testRunResp); + }; + } + } + + describe('should pass error back to the user', async () => { + beforeEach(() => { + // Mock out begin transaction and send error back to the user + // from the Gapic layer. + setupBeginTransaction(new Error(testErrorMessage)); + }); + + it('should send back the error when awaiting a promise', async () => { + try { + await transactionWithoutMock.run(); + assert.fail('The run call should have failed.'); + } catch (error: any) { + assert.strictEqual(error['message'], testErrorMessage); + } + }); + it('should send back the error when using a callback', done => { + const runCallback: RunCallback = ( + error: Error | null, + transaction: Transaction | null, + response?: google.datastore.v1.IBeginTransactionResponse, + ) => { + try { + assert(error); + assert.strictEqual(error.message, testErrorMessage); + assert.strictEqual(transaction, null); + assert.strictEqual(response, testRunResp); + done(); + } catch (e) { + done(e); + } + }; + transactionWithoutMock.run({}, runCallback); + }); + }); + describe('should pass response back to the user', async () => { + beforeEach(() => { + // Mock out begin transaction and send a response + // back to the user from the Gapic layer. + setupBeginTransaction(null); + }); + it('should send back the response when awaiting a promise', async () => { + const [transaction, resp] = await transactionWithoutMock.run(); + assert.strictEqual(transaction, transactionWithoutMock); + assert.strictEqual(resp, testRunResp); + }); + it('should send back the response when using a callback', done => { + const runCallback: RunCallback = ( + error: Error | null, + transaction: Transaction | null, + response?: google.datastore.v1.IBeginTransactionResponse, + ) => { + try { + assert.strictEqual(error, null); + assert.deepStrictEqual(response, testRunResp); + assert.strictEqual(transaction, transactionWithoutMock); + done(); + } catch (e) { + done(e); + } + }; + transactionWithoutMock.run({}, runCallback); + }); + }); + }); + + describe('commit', () => { + beforeEach(done => { + transaction.id = TRANSACTION_ID; + transaction.request_ = (config, callback) => { + callback(null, { + transaction: Buffer.from(Array.from(Array(100).keys())), + }); + // Delay to give the transaction mutex the opportunity to unlock before running tests. + setImmediate(() => { + done(); + }); + }; + void transaction.run(); + }); + + afterEach(() => { + sinon.restore(); + }); + + it('should commit', done => { + transaction.request_ = config => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'commit'); + assert.deepStrictEqual(config.gaxOpts, {}); + done(); + }; + void transaction.commit(); + }); + + it('should accept gaxOptions', done => { + const gaxOptions = {}; + + transaction.request_ = config => { + assert.deepStrictEqual(config.gaxOpts, {}); + done(); + }; + + void transaction.commit(gaxOptions); + }); + + it('should skip the commit', done => { + transaction.skipCommit = true; + + // If called, the test will blow up. + transaction.request_ = done; + + transaction.commit(done); + }); + + describe('errors', () => { + const error = new Error('Error.'); + const apiResponse = {}; + + const rollbackError = new Error('Error.'); + const rollbackApiResponse = {}; + + beforeEach(() => { + transaction.rollback = ((callback: Function) => { + callback(rollbackError, rollbackApiResponse); + }) as Any; + + transaction.request_ = (config, callback) => { + callback(error, apiResponse); + }; + }); + + it('should pass the commit error to the callback', done => { + transaction.commit((err, resp) => { + assert.strictEqual(err, error); + assert.strictEqual(resp, apiResponse); + done(); + }); + }); + }); + + it('should pass apiResponse to callback', done => { + const resp = {success: true}; + transaction.request_ = (config, callback) => { + callback(null, resp); + }; + transaction.commit((err, apiResponse) => { + assert.ifError(err); + assert.deepStrictEqual(resp, apiResponse); + done(); + }); + }); + + it('should group mutations & execute original methods', () => { + const deleteArg1 = key(['Product', 123]); + const deleteArg2 = key(['Product', 234]); + + const saveArg1 = {key: key(['Product', 345]), data: ''}; + const saveArg2 = {key: key(['Product', 456]), data: ''}; + + // Queue saves & deletes in varying order. + transaction.delete(deleteArg1); + transaction.save(saveArg1); + transaction.delete(deleteArg2); + transaction.save(saveArg2); + + const args: Array<{}> = []; + + const deleteStub = sinon + .stub(Datastore.prototype, 'delete') + .callsFake(a => { + args.push(a); + }); + const saveStub = sinon + .stub(Datastore.prototype, 'save') + .callsFake(a => { + args.push(a); + }); + + transaction.request_ = () => {}; + + void transaction.commit(); + + assert.strictEqual(deleteStub.calledOnce, true); + assert.strictEqual(saveStub.calledOnce, true); + + assert.strictEqual(args.length, 2); + + // Save arguments must come first. + assert.deepStrictEqual(args, [ + [saveArg1, saveArg2], + [deleteArg1, deleteArg2], + ]); + }); + + it('should honor ordering of mutations (last wins)', () => { + // The delete should be ignored. + transaction.delete(key(['Product', 123])); + transaction.save({key: key(['Product', 123]), data: ''}); + + const deleteSpy = sinon + .stub(Datastore.prototype, 'delete') + .callsFake(() => {}); + const saveStub = sinon + .stub(Datastore.prototype, 'save') + .callsFake(() => {}); + + transaction.request_ = () => {}; + + void transaction.commit(); + assert.strictEqual(deleteSpy.notCalled, true); + assert.strictEqual(saveStub.calledOnce, true); + }); + + it('should not squash key-incomplete mutations', done => { + transaction.save({key: key(['Product']), data: ''}); + transaction.save({key: key(['Product']), data: ''}); + + sinon + .stub(Datastore.prototype, 'save') + .callsFake((entities: Entity[]) => { + assert.strictEqual(entities.length, 2); + done(); + }); + + transaction.request_ = () => {}; + + void transaction.commit(); + }); + + it('should send the built request object', done => { + transaction.requests_ = [ + { + mutations: [{a: 'b'}, {c: 'd'}], + }, + { + mutations: [{e: 'f'}, {g: 'h'}], + }, + ]; + + transaction.request_ = config => { + assert.deepStrictEqual(config.reqOpts, { + mutations: [{a: 'b'}, {c: 'd'}, {e: 'f'}, {g: 'h'}], + }); + done(); + }; + + void transaction.commit(); + }); + + it('should execute the queued callbacks', () => { + let cb1Called = false; + let cb2Called = false; + + transaction.requestCallbacks_ = [ + () => { + cb1Called = true; + }, + () => { + cb2Called = true; + }, + ]; + + transaction.request_ = (config, cb) => { + cb(); + }; + + void transaction.commit(); + + assert(cb1Called); + assert(cb2Called); + }); + }); + + describe('createQuery', () => { + it('should return query from datastore.createQuery', () => { + const args = ['0', '1']; // Query only accepts to accept string||null values + const createQueryReturnValue = {}; + + transaction.datastore.createQuery = function (...ags: Any) { + assert.strictEqual(this, transaction); + assert.strictEqual(ags[0], args[0]); + assert.strictEqual(ags[1], args[1]); + return createQueryReturnValue as Query; + }; + + const query = transaction.createQuery(args[0], args[1]); // verbose de-structure + assert.strictEqual(query, createQueryReturnValue); + }); + }); + + describe('delete', () => { + it('should push entities into a queue', () => { + const keys = [ + key('Product123'), + key('Product234'), + key('Product345'), + ]; + + transaction.delete(keys); + + assert.strictEqual(transaction.modifiedEntities_.length, keys.length); + + transaction.modifiedEntities_.forEach((queuedEntity: Entity) => { + assert.strictEqual(queuedEntity.method, 'delete'); + assert(keys.indexOf(queuedEntity.entity.key) > -1); + assert.deepStrictEqual(queuedEntity.args, [ + queuedEntity.entity.key, + ]); + }); + }); + }); + + describe('insert', () => { + afterEach(() => { + sinon.restore(); + }); + + it('should prepare entity objects', done => { + const entityObject = {}; + const preparedEntityObject = {prepared: true}; + const expectedEntityObject = Object.assign({}, preparedEntityObject, { + method: 'insert', + }); + + sinon + .stub(DatastoreRequest, 'prepareEntityObject_') + .callsFake(obj => { + assert.strictEqual(obj, entityObject); + return preparedEntityObject as {}; + }); + + transaction.save = (entities: Entity[]) => { + assert.deepStrictEqual(entities[0], expectedEntityObject); + done(); + }; + + transaction.insert(entityObject); + }); + + it('should pass the correct arguments to save', done => { + transaction.save = (entities: Entity[]) => { + assert.deepStrictEqual(JSON.parse(JSON.stringify(entities)), [ + { + key: { + namespace: 'ns', + kind: 'Company', + path: ['Company', null], + }, + data: {}, + method: 'insert', + }, + ]); + done(); + }; + const key = new entity.Key({namespace: 'ns', path: ['Company']}); + transaction.insert({key, data: {}}); + }); + }); + + describe('rollback', () => { + beforeEach(done => { + // The transaction state needs to be set to IN_PROGRESS in order for + // the rollback function to reach request_. + transaction.request_ = ( + config: RequestConfig, + callback: RequestCallback, + ) => { + callback(null, {transaction: Buffer.from(TRANSACTION_ID)}); + }; + transaction.run(() => { + done(); + }); + }); + + it('should rollback', done => { + transaction.request_ = config => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'rollback'); + assert.deepStrictEqual(config.gaxOpts, {}); + done(); + }; + void transaction.rollback(); + }); + + it('should allow setting gaxOptions', done => { + const gaxOptions = {}; + + transaction.request_ = config => { + assert.strictEqual(config.gaxOpts, gaxOptions); + done(); + }; + + void transaction.rollback(gaxOptions); + }); + + it('should pass error to callback', done => { + const error = new Error('Error.'); + transaction.request_ = (config, callback) => { + callback(error); + }; + transaction.rollback(err => { + assert.deepStrictEqual(err, error); + done(); + }); + }); + + it('should pass apiResponse to callback', done => { + const resp = {success: true}; + transaction.request_ = (config, callback) => { + callback(null, resp); + }; + transaction.rollback((err, apiResponse) => { + assert.ifError(err); + assert.deepStrictEqual(resp, apiResponse); + done(); + }); + }); + + it('should set skipCommit', done => { + transaction.request_ = (config, callback) => { + callback(); + }; + transaction.rollback(() => { + assert.strictEqual(transaction.skipCommit, true); + done(); + }); + }); + + it('should set skipCommit when rollback errors', done => { + transaction.request_ = (config, callback) => { + callback(new Error('Error.')); + }; + transaction.rollback(() => { + assert.strictEqual(transaction.skipCommit, true); + done(); + }); + }); + }); + + describe('run', () => { + it('should make the correct API request', done => { + transaction.request_ = config => { + assert.strictEqual(config.client, 'DatastoreClient'); + assert.strictEqual(config.method, 'beginTransaction'); + assert.deepStrictEqual(config.reqOpts, {transactionOptions: {}}); + assert.strictEqual(config.gaxOpts, undefined); + done(); + }; + + transaction.run(assert.ifError); + }); + + it('should allow setting gaxOptions', done => { + const gaxOptions = {}; + + transaction.request_ = config => { + assert.strictEqual(config.gaxOpts, gaxOptions); + done(); + }; + + void transaction.run({gaxOptions}); + }); + + describe('options.readOnly', () => { + it('should respect the readOnly option', done => { + const options = { + readOnly: true, + }; + + transaction.request_ = (config: Any) => { + assert.deepStrictEqual( + config.reqOpts.transactionOptions.readOnly, + {}, + ); + done(); + }; + + transaction.run(options, assert.ifError); + }); + + it('should respect the global readOnly option', done => { + transaction.readOnly = true; + + transaction.request_ = config => { + assert.deepStrictEqual( + config.reqOpts!.transactionOptions!.readOnly, + {}, + ); + done(); + }; + + transaction.run(assert.ifError); + }); + }); + + describe('options.transactionId', () => { + it('should respect the transactionId option', done => { + const options = { + transactionId: 'transaction-id', + }; + + transaction.request_ = config => { + assert.deepStrictEqual( + config.reqOpts!.transactionOptions!.readWrite, + { + previousTransaction: options.transactionId, + }, + ); + done(); + }; + + transaction.run(options, assert.ifError); + }); + + it('should respect the global transactionId option', done => { + transaction.id = 'transaction-id'; + + transaction.request_ = config => { + assert.deepStrictEqual( + config.reqOpts!.transactionOptions!.readWrite, + { + previousTransaction: transaction.id, + }, + ); + done(); + }; + + transaction.run(assert.ifError); + }); + }); + + describe('options.transactionOptions', () => { + it('should allow full override of transactionOptions', done => { + transaction.readOnly = true; + + const options = { + transactionOptions: { + readWrite: { + previousTransaction: 'transaction-id', + }, + }, + } as {} as TransactionOptions; + const inputOptions = { + transactionOptions: { + id: 'transaction-id', + }, + }; + + transaction.request_ = (config: RequestConfig) => { + assert.deepStrictEqual(config.reqOpts, options); + done(); + }; + + transaction.run(inputOptions, assert.ifError); + }); + }); + + describe('error', () => { + const error = new Error('Error.'); + const apiResponse = {}; + + beforeEach(() => { + transaction.request_ = (config, callback) => { + callback(error, apiResponse); + }; + }); + + it('should pass error & API response to callback', done => { + transaction.run((err, transaction, apiResponse_) => { + assert.strictEqual(err, error); + assert.strictEqual(transaction, null); + assert.strictEqual(apiResponse_, apiResponse); + done(); + }); + }); + }); + + describe('success', () => { + const apiResponse = { + transaction: TRANSACTION_ID, + }; + + beforeEach(() => { + transaction.request_ = (config, callback) => { + callback(null, apiResponse); + }; + }); + + it('should set transaction id', done => { + delete transaction.id; + transaction.run((err: Error | null) => { + assert.ifError(err); + assert.strictEqual(transaction.id, TRANSACTION_ID); + done(); + }); + }); + + it('should exec callback with Transaction & apiResponse', done => { + transaction.run((err, transaction_, apiResponse_) => { + assert.ifError(err); + assert.strictEqual(transaction_, transaction); + assert.deepStrictEqual(apiResponse_, apiResponse); + done(); + }); + }); + }); + }); + + describe('save', () => { + it('should push entities into a queue', () => { + const entities = [ + {key: key('Product123'), data: 123}, + {key: key('Product234'), data: 234}, + {key: key('Product345'), data: 345}, + ]; + transaction.save(entities); + assert.strictEqual( + transaction.modifiedEntities_.length, + entities.length, + ); + transaction.modifiedEntities_.forEach((queuedEntity: Entity) => { + assert.strictEqual(queuedEntity.method, 'save'); + const match = entities.filter(ent => { + return ent.key === queuedEntity.entity.key; + })[0]; + assert.deepStrictEqual(queuedEntity.args, [match]); + }); + }); + }); + + describe('update', () => { + afterEach(() => { + sinon.restore(); + }); + + it('should prepare entity objects', done => { + const entityObject = {}; + const preparedEntityObject = {prepared: true}; + const expectedEntityObject = Object.assign({}, preparedEntityObject, { + method: 'update', + }); + + sinon + .stub(DatastoreRequest, 'prepareEntityObject_') + .callsFake(obj => { + assert.strictEqual(obj, entityObject); + return preparedEntityObject as {}; + }); + + transaction.save = (entities: Entity[]) => { + assert.deepStrictEqual(entities[0], expectedEntityObject); + done(); + }; + + transaction.update(entityObject); + }); + + it('should pass the correct arguments to save', done => { + transaction.save = (entities: Entity[]) => { + assert.deepStrictEqual(JSON.parse(JSON.stringify(entities)), [ + { + key: { + namespace: 'ns', + kind: 'Company', + path: ['Company', null], + }, + data: {}, + method: 'update', + }, + ]); + done(); + }; + const key = new entity.Key({namespace: 'ns', path: ['Company']}); + transaction.update({key, data: {}}); + }); + }); + + describe('upsert', () => { + afterEach(() => { + sinon.restore(); + }); + + it('should prepare entity objects', done => { + const entityObject = {}; + const preparedEntityObject = {prepared: true}; + const expectedEntityObject = Object.assign({}, preparedEntityObject, { + method: 'upsert', + }); + + sinon + .stub(DatastoreRequest, 'prepareEntityObject_') + .callsFake(obj => { + assert.strictEqual(obj, entityObject); + return preparedEntityObject as {}; + }); + + transaction.save = (entities: Entity[]) => { + assert.deepStrictEqual(entities[0], expectedEntityObject); + done(); + }; + + transaction.upsert(entityObject); + }); + + it('should pass the correct arguments to save', done => { + transaction.save = (entities: Entity[]) => { + assert.deepStrictEqual(JSON.parse(JSON.stringify(entities)), [ + { + key: { + namespace: 'ns', + kind: 'Company', + path: ['Company', null], + }, + data: {}, + method: 'upsert', + }, + ]); + done(); + }; + const key = new entity.Key({namespace: 'ns', path: ['Company']}); + transaction.upsert({key, data: {}}); + }); + }); + }); + }, +); + +describe('getTransactionRequest', () => { + const datastore = new Datastore(); + + it('should return an empty object if no options are provided', () => { + const transaction = new Transaction(datastore); + const options = {}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, {}); + }); + + it('should return a readOnly object if readOnly is true', () => { + const transaction = new Transaction(datastore); + const options = {readOnly: true}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, {readOnly: {}}); + }); + + it('should return a readWrite object with previousTransaction if transactionId is provided', () => { + const transaction = new Transaction(datastore); + const options = {transactionId: 'transaction-id'}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, { + readWrite: {previousTransaction: 'transaction-id'}, + }); + }); + + it('should return a readWrite object with previousTransaction if transaction.id is provided', () => { + const transaction = new Transaction(datastore, {id: 'transaction-id'}); + const options = {}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, { + readWrite: {previousTransaction: 'transaction-id'}, + }); + }); + + it('should return a readOnly object if transactionOptions.readOnly is true', () => { + const transaction = new Transaction(datastore); + const options = {transactionOptions: {readOnly: true}}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, {readOnly: {}}); + }); + + it('should return a readWrite object with previousTransaction if transactionOptions.id is provided', () => { + const transaction = new Transaction(datastore); + const options = {transactionOptions: {id: 'transaction-id'}}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, { + readWrite: {previousTransaction: 'transaction-id'}, + }); + }); + + it('should prioritize transactionOptions over other options', () => { + const transaction = new Transaction(datastore); + const options = { + readOnly: false, + transactionId: 'transaction-id-1', + transactionOptions: { + readOnly: true, + id: 'transaction-id-2', + }, + }; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, { + readOnly: {}, + }); + }); + + it('should return a readOnly object if transaction is constructed with readOnly: true', () => { + const transaction = new Transaction(datastore, {readOnly: true}); + const options = {}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, {readOnly: {}}); + }); + + it('should return a readWrite object with previousTransaction if transaction is constructed with id', () => { + const transaction = new Transaction(datastore, {id: 'transaction-id'}); + const options = {}; + const result = getTransactionRequest(transaction, options); + assert.deepStrictEqual(result, { + readWrite: {previousTransaction: 'transaction-id'}, + }); + }); +}); diff --git a/handwritten/nodejs-datastore/test/try-server.ts b/handwritten/nodejs-datastore/test/try-server.ts new file mode 100644 index 00000000000..28f67d0d7db --- /dev/null +++ b/handwritten/nodejs-datastore/test/try-server.ts @@ -0,0 +1,33 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.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. + +import {describe, it} from 'mocha'; +import {Datastore} from '../src'; + +import {startServer} from '../mock-server/datastore-server'; + +describe('Try server', () => { + it.skip('should try to connect to the running server', done => { + startServer(async () => { + const datastore = new Datastore({ + namespace: `${Date.now()}`, + apiEndpoint: 'localhost:50051', + }); + const postKey = datastore.key(['Post', 'post1']); + const query = datastore.createQuery('Post').hasAncestor(postKey); + const allResults = await datastore.runQuery(query); + done(); + }); + }); +}); diff --git a/handwritten/nodejs-datastore/tsconfig.json b/handwritten/nodejs-datastore/tsconfig.json new file mode 100644 index 00000000000..894ecb34c02 --- /dev/null +++ b/handwritten/nodejs-datastore/tsconfig.json @@ -0,0 +1,26 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "types": [ + "long" + ], + "resolveJsonModule": true, + "lib": [ + "es2018", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts", + "mock-server/datastore-server.ts", + "src/v1/datastore_client_config.json", + "protos/protos.json", + "src/v1/datastore_admin_client_config.json" + ] +} diff --git a/handwritten/nodejs-datastore/webpack.config.js b/handwritten/nodejs-datastore/webpack.config.js new file mode 100644 index 00000000000..f37985e3589 --- /dev/null +++ b/handwritten/nodejs-datastore/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: 'datastore', + filename: './datastore.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/release-please-config.json b/release-please-config.json index 9c211610789..fbd4fff0b52 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -1,6 +1,8 @@ { + "bump-minor-pre-major": true, "initial-version": "0.1.0", "packages": { + "handwritten/nodejs-datastore": {}, "packages/gapic-node-processing": {}, "packages/google-ads-admanager": {}, "packages/google-ads-datamanager": {}, @@ -149,11 +151,11 @@ "packages/google-cloud-saasplatform-saasservicemgmt": {}, "packages/google-cloud-scheduler": {}, "packages/google-cloud-secretmanager": {}, + "packages/google-cloud-securesourcemanager": {}, "packages/google-cloud-security-privateca": {}, "packages/google-cloud-security-publicca": {}, "packages/google-cloud-securitycenter": {}, "packages/google-cloud-securitycentermanagement": {}, - "packages/google-cloud-securesourcemanager": {}, "packages/google-cloud-servicedirectory": {}, "packages/google-cloud-servicehealth": {}, "packages/google-cloud-shell": {}, @@ -227,6 +229,5 @@ "type": "sentence-case" } ], - "bump-minor-pre-major": true, "release-type": "node" } \ No newline at end of file